this might be a rookie question, but how would you efficiently apply regex expressions on strings to retrieve parts of the string ? I have a concrete parsing to solve as an example.
If I have the string :
STRING[(val1)-{val2}-!val3!]
or
STRING[{val2}-!val3!-(val1)]
or
STRING[!val3!-(val1)-{val2}]
etc… (All 8 permutations of !val3!,(val2),{val1} that I won’t bother you with).
I can do several easy finds and splits on that to achieve my purpose, but how would you do things in a clean and safe way to get something like :
val1,val2,val3 = ... ?
UPDATE : in the string to parse, val1, val2 and val3 are variable inputs, and the three delimiters !! () {} are there to help me know where are the three values that each have another semantic meaning.
You can use lookahead assertions with capturing groups to find matches in any order:
Then you can do