Topic How to find not allowed characters?

fmika started the topic:
2015-12-18 15:38

How to find not allowed characters?

Hi,
before search/replace in the string field I would need to check if strings contain not allowed characters like "&", " ' " , "\", etc. Shall I construct the specific string pattern, how? Or shall I use other string manipulation tool?
Kasper Sørensen replied:
2015-12-23 10:53
I would suggest to use Regex Parser for that, matching on something like ([\$\'\\]+)
Beverly replied:
2017-05-01 16:32
Never heard of Regex Parser (mainframe know If ... then ELSE...) where would you code the ([\$\'\\]+) and how is this handling not allowed characters "&", " ' " , "\"?
Dennis replied:
2017-05-02 09:31
Hi Berverly,

The regex parser is a component found under "Transform"/"Text"/"Regex parser", you can read about it here.

In this case, it would simply contain the value if it is present, then you could report on that. If you want to instead _remove_ those characters, I'd suggest using Plain search/replace for specific characters, or Remove unwanted characters for more general removal of punctuation.
Beverly replied:
2017-05-02 13:06
I meant how is "&", " ' " , "\", in this - ([\$\'\\]+) . Not allowed character & - not even there. Several \ and one '. Are we checking everything within the [ ]? Doesn't seem paired? Do I need to know Java? Only know COBOL.
Dennis replied:
2017-05-03 12:40
Ah. That is an example of a regular expression. A powerful, but admittedly complex (though not as hard to learn as it seems at first) way to do string parsing and matching.

I think Kasper was just using a $ instead of an & by mistake. The regular expression how showed would find one or more $ or ' or \ characters.

If you want, you can read a regex tutorial on regexone.com. A good place to check out how a specific regular expression works, or to test your own, is regex101.com. Try filling in the regular expression Kasper showed, then you can see all parts to it (a little experience is needed to understand all of it, but it should give a good idea on how it works).

BR,
Dennis
You are not signed in.
You need to be signed in to participate in the discussion.