in reply to Re: Recursively executed function in regex RHS, AKA "wait, why does this work?"
in thread Recursively executed function in regex RHS, AKA "wait, why does this work?"

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.

  • Comment on Re^2: Recursively executed function in regex RHS, AKA "wait, why does this work?"
  • Download Code