A complex recursive regex,helpby OM_Zen (Scribe)
|on Feb 06, 2003 at 00:40 UTC||Need Help??|
OM_Zen has asked for the
wisdom of the Perl Monks concerning the following question:
Hi , Great Monks of the Monastery ,please help on this
The string above has this pattern x|xx|x ,that has to be changed to x|x x|x,( my intent is to change |xx| alone to |x x| and not any other occurances of xx ) when I am doing this , the part of the code that has the pattern like x|xx|xx|x is changed to x|x x|xx|x, I understand that when the string is parsed and the pattern of x|xx|x occurs , it is changed to x|x x|x, but the next time when it occurs together the parser would have crossed the pattern and hence changes only the first occurance and leaves the second one as it was in the string .
I am asking the way to recursively do pattern matching or doing backtracking or something to match the second pattern as well
Alternately , a colleague had a while loop going
I have come to the monastery for an answer that will be in doing this recursively or through some other pattern to do this through regular expression itself
20030208 Edit by Corion - changed text from within code to normal text.