in reply to Re^2: substitution in regular expression
in thread substitution in regular expression
Short explanation: (?{...}) means to execute arbitrary Perl code inside a regular expression, and (?!) makes the regex engine to fail and backtrack, trying to match from the last_pos + 1. When it starts matching ABC, it prints it, fails, backtracks and starts matching from B the next three letters, giving us BCD. The process repeats until the internal regex counter reaches the end of the string.
I know, I'm really bad at explaining things to humans, but, fortunately, Athanasius explained this better once.
Please see: Re: RegEx + vs. {1,}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: substitution in regular expression
by aeqr (Novice) on Apr 23, 2014 at 23:05 UTC |