filtering non-alphanumeric chars in processing

Bruce Easton bruce at stn.com
Thu Feb 26 16:14:03 PST 2015


Testing has shown the code using the result of the edit application to 
work well for the requirement:

Then:  an(1,alnum)=x
Then:  x=an   'returns original char (even if space), or space from edit fail

(the code above is already in mid-stream in processing a string; "x" is (1,*))

Although I haven't yet tested that against other techniques for efficiency.  I can't imagine that any other techniques mentioned so far would be any more runtime efficient. Thankfully, it's also easy to apply and understand later should I need to revisit the code.




On 2/26/15 5:19 PM, Richard Kreiss wrote:
> Top post:
>
> Bruce,
>
> Have you considered using xlate() to remove all of the acceptable characters.  If the resulting filed is blank, do nothing.
>
> If it isn't blank, you will have all of the characters you want to replace with a space.
>
> Using the xlate field to replace the character with a space.
>
> Qq=xlate(a,"~"," ") - this would replace the tilde with a space. Or you could use asc() or chr() for the character to be replaced.
>
> Keep looping through the field which contains the characters to be replaced.
>
> Just a thought.
>
> Richard Kreiss
>
>> -----Original Message-----
>> From: Filepro-list [mailto:filepro-list-
>> bounces+rkreiss=verizon.net at lists.celestial.com] On Behalf Of Bruce Easton
>> Sent: Thursday, February 26, 2015 2:22 PM
>> To: filepro-list at lists.celestial.com
>> Subject: Re: filtering non-alphanumeric chars in processing
>>
>> Yeah, that was one option I was considering and may yet test for runtime
>> efficiency.  The requirement turned out to be a little different in the end
>> though.  What was needed was not squishing, but to replace the non-
>> alphanumeric with a space as it gets fed to the output string. For now, I'm
>> testing with a simple edit assignment:
>>
>> Then:  an(1,alnum)=x
>> Then:  x=an      'should get original char (even if space), or space
>> from edit failure
>>
>> Bruce
>>
>> On 2/26/15 1:35 PM, Scott Nelson wrote:
>>> Test each character for it's ascii value v the desired range:
>>>
>>> ::l="'1"
>>> loop:l eq "100":end
>>> ::c=mid(f,l,"1");d=asc(c)
>>> :(d ge "48" and d le "57") or (d ge "65" and d le "90") or (d ge "97"
>>> and d le "122"):   do something to keep this digit
>>> :::  or do something else
>>> :::l=l+"1";goto loop
>>>
>>>
>>> Scott
>>>
>>>
>>>
>>>
>>> On 02/26/2015 12:03 PM, Bruce Easton wrote:
>>>> I need to filter out (squish out) non-alphanumeric characters from
>>>> small array-element strings in processing for a large amount of data.
>>>>
>>>> Since I am already having to, for other purposes form each string
>>>> character by character, I'm wondering which might be more efficient
>>>> at runtime (or if there would even be any noticeable difference).
>>>>
>>>> For each character, I could test its inclusion in the desired ascii
>>>> range using the asc() function; or for each, I could set an
>>>> "okstring" to "0123...9abc...z" and then test if the char is
>>>> contained in said okstring; or for each, I could apply the char to a
>>>> dummy with the alnum edit and then test if the dummy is left blank.
>>>>
>>>> Just wondering out loud.  I haven't tried any of these against a
>>>> large data set - but ultimately this will be used for such, so I
>>>> should soon know.  I have a feeling testing against the edit result
>>>> might be the most efficient.
>>>>
>>>> Bruce
>>>>
>>>> _______________________________________________
>>>> Filepro-list mailing list
>>>> Filepro-list at lists.celestial.com
>>>> Subscribe/Unsubscribe/Subscription Changes
>>>> http://mailman.celestial.com/mailman/listinfo/filepro-list
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Filepro-list mailing list
>>> Filepro-list at lists.celestial.com
>>> Subscribe/Unsubscribe/Subscription Changes
>>> http://mailman.celestial.com/mailman/listinfo/filepro-list
>>>
>>
>> _______________________________________________
>> Filepro-list mailing list
>> Filepro-list at lists.celestial.com
>> Subscribe/Unsubscribe/Subscription Changes
>> http://mailman.celestial.com/mailman/listinfo/filepro-list




More information about the Filepro-list mailing list