You're still right about /g being necessary for this to work. The recursion processes the descendants and the /g modifier makes sure all siblings are processed. There are actually two loop-like constructs in this code. s/REG/REPL/g does not however process the replaced text, or something like s/(.)/$1$1/g; would be an infinite loop.
In reply to Re^2: Recursively executed function in regex RHS, AKA "wait, why does this work?"
by Eily
in thread Recursively executed function in regex RHS, AKA "wait, why does this work?"
by Cody Fendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |