Posted: 13 Feb 2018 11:01 EST Last activity: 1 Mar 2018 10:32 EST
Regular Expression to extract a substring?
Here's the problem:
You have an arbitrary length string (it could be a 2000 character string or more) that you have to extract a substring from. The easiest way I know is using RegEx. The hardest way I know is using an activity with when/loops.
I'm not too particularly fond of creating a whole new activity with different when/loops when I have to look for a completely different substring, or when I'm looking for the same substring in a completely different formatted string.
The only out-of-the-box RegEx I can find in 7.1.x is from String (Pega-RulesEngine) in expression builder, however they don't extract substrings with RegEx.
so I'm left with using a Java step with the code below.
The only OOTB substring functions I found was under String (Pega-RULES). However, they still require me to do the work of knowing the exact index of the substring. Do you know any substring methods that doesn't require that? The RegEx under Java steps doesn't require me to do that, and I'm trying to find a OOTB replacement for the Java Step.
It turns out for simple strings, you don't need regex. You can use substring functions for that. For large complicated strings, you definitely need Regex. Otherwise it becomes too difficult to implement an activity to extract a substring.
I still couldn't find any out of the box regex functions for extracting a substring. The only way to this is still the Java steps.