TSO Regular Expression Testing Tool
MartinPacker 11000094DH Comments (3) Visits (11065)
I’ll admit I’ve found regular expressions a bit of a struggle. I bet most people have. For me it’s a matter of lots of arcane symbols that don’t have any inherent meaning. Contrast with many programming languages, which do have some.
It’s also not the case I don’t understand the concepts.
Anyhow I’m edging towards the point where Production code will need to allow regexes. So I want to take a list of space-separated names and see which items match a given regular expression.
For example a list of address space names..
And so the FL (for “Filter List”) REXX EXEC was born.
The code is below. It uses grep to do the testing and BPXWUNIX invokes grep.
You invoke it with
if you’ve put it in a suitable CLIST library. Mine is in my ISPF one. I can also call it from ISPF Option 6 or from Batch.
Will display the string
as these two items match the regular expression.
Obviously this could be modified to be a callable routine, or to use one. In this simple sample I thought it best to leave it as open code.
You could probably also find a way to pass parameters to grep like -i for case insensitivity.
One further refinement which is more of a stretch is handling list items with a space in them: You’d need to rewrite the bit that creates stem variables from the words in the list string. But for my purposes I’m looking at names which don’t have spaces in them.
Observant readers will spot this code is derived from Filtering REXX Query Results With BPXWUNIX but this version is easy to prototype with from the command line.
If you’re wanting to get started with regular expressions have a play with it. Enjoy!