I need to capture $&, $-[0], etc. of each match. Unfortunately, this gives me only the last set:
while (s/this/that/g){...}
And this starts the matching at the beginning of the string each time:
whie (s/this/that/){...}
Is there a way to stop and evaluate each time the /g matches (without using the /e modifier)?
Thanks. I must have read right through the docs regarding the \G assertion. That should do the trick.
>>>>Just as a matter of curiosity, what is the reason for this requirement?
We have a legacy system in which perl substitutions (thousands of them) are kept as lists in separate files and are read in by a processing engine, which then essentially does this: eval $mySubstitution. We now need to keep track of what was matched and their positions in the document. Of course we don't want to rewrite all these substitutions: we can have the engine manipulate the regex strings a bit as it reads them in, but not make major changes.
In reply to Loop through global substitution by alafarm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |