I would like to be able to match a specific sequence of characters, starting with a specific substring and ending with a specific substring. My positive regex works if there is only one instance in the string, but not if there should be multiple matches in the string. I understand this because (. +) Grabs everything until the last positive expression is found. It would be nice if he captured everything until the first expression was found.
Here is my regex attempt:
@@FOO\[(.*)(?=~~)~~(.*)(?=\]@@)\]@@
Input Example:
@@FOO[abc~~hi]@@ @@FOO[def~~hey]@@
Desired conclusion: 2 matches, two suitable groups (abc, hi) and (def, hey) each.
Actual conclusion: 1 corresponds to two groups (abc ~~ hi] @@@@ FOO [def, hey)
Is there any way to get the desired result?
Thanks in advance!
source
share