Strip non-alphanumeric characters from strings

Discussion forum about all things Gupta, OpenText and the community.
ACTHSS

Strip non-alphanumeric characters from strings

Post by ACTHSS » 06 Jan 2015, 03:34

Given a datafield which takes user input, I want to strip all non-alphanumeric characters from this field before passing it into an SQL statement. Is there a regexp-like function to achieve this?

Thanks in advance,
John

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 2370
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: Strip non-alphanumeric characters from strings

Post by Jeff Luther » 07 Jan 2015, 18:58

Regexp function... I think there is, if you know what the "non-alphanumeric characters" list is.

I have a RegExp sample I just updated with a v5.2 version and posted in the Samples section of my TD page: http://www.jeffluther.net/TD/#Code_Samples
Samples are listed in alpha order by title. Scroll down to find RegExp.

RegExp.zip now contains a 5.2 sample I had modified to use a later version of the include APL: Microsoft VBScript Regular Expressions 5.5.apl
which is included in the zip. Run the demo and look at the valid vs. invalid email addresses test. The list of valid chars, in this case, is contained in the constant. Your list on non-alpha chars. would be contained in a similar constant.

If you cannot get it to work, then zip together your own test + the APL and attach here so myself or another can look at it.
Jeff Luther @ PC Design
Palm Springs, California

ACTHSS

Re: Strip non-alphanumeric characters from strings

Post by ACTHSS » 08 Jan 2015, 01:19

Thanks for the reply and the update, Jeff. Unfortunately I have an issue trying to get your sample to work: I don't seem to have automation.apl for some reason. Would you be able to share this library with me?

Cheers
John

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 2370
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: Strip non-alphanumeric characters from strings

Post by Jeff Luther » 12 Jan 2015, 17:56

Sure. (Sorry I haven't replied sooner to you...) Note that I believe automation.apl is generated for your given version of TD the first time that you generate an apl via ActiveX Explorer.

Anyway, attached is my copy for TD v5.2.
You do not have the required permissions to view the files attached to this post.
Jeff Luther @ PC Design
Palm Springs, California

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 2 guests