Hello again Richard
ST has a number of regex type methods and you have already identified some of them.
I won’t bother saying what these do, as that information should be readily available in the docs, but FWIW here is a list:
Match
FindMatch
FindMatchPosition
SplitByMatch
I agree that it would be a good idea if Bruce were to list these (and any others I may have forgotten) under the Regular Expressions section of the docs.
As mentioned earlier at Need help with some text functions - #40 by vitesse I don’t consider KeepCharRanges and RemoveCharRanges to be regex even though it has the ability to deal with character ranges such as:
‘A-Za-z0-9’
‘<0>-<31>’ and so on.
I think your StrPosProcess has different functionality compared to what ST offers, but it would most likely be easier to write your function using ST compared to straight Clarion as it allows you to think at a higher level and not worry about the low-level details where “off by one” errors often occur. And the existing ST regex methods would likely get you some of the way there.
For example dealing with leading or trailing spaces is trivial, and the start and end position are available using FindMatchPosition so from those again it is a simple matter to get the string before and after. Mind you, FindMatch and FindMatchPosition return the minimum matched size, so you would have to do further checks if you wanted to get the maximum match - basically just try one more char then another in a loop until the regex no longer matches.
Aside: you may recall we did discuss this back in June 2022, see:
ST has a similar idea in the method FindNth and its various related methods like AfterNth, SetAfterNth, BeforeNth, SetBeforeNth, ReplaceNth, but these are for simple strings not regex.
I have done a fair bit of that kind of work in the past and find ST invaluable, especially the various Split options.
cheers for now
Geoff R