eibwen has asked for the wisdom of the Perl Monks concerning the following question:
Is
really the same as/ ( (?<=prefix) (infix) (?=suffix) ) (??{ print $^N }) /gx
as far as $^N = 'infix' is concerned? Actually I can't seem to find any net differences in the above. I came to this presumption after having used the former for awhile and tested it with a fairly simple RE (such as the above), but wanted to confirm this is universally true for literal strings and ask if it might break otherwise./ prefix (infix) suffix (??{ print $^N }) /gx
Similarly, if they are equivalent, why doesn't
optimize away to/ ( (?<=some(optional)?prefix) (infix) (?=suffix) ) (??{ print $^N }) /gx
instead of resulting in the Variable length lookbehind not implemented in regex error?/ some(optional)?prefix (infix) suffix (??{ print $^N }) /gx
Lastly, (this might be redundant given answers to the above, but) when is usage of ?<= and ?= appropriate? The only possibility I can think of is something involving nested (), but I can only think of contrived examples at the moment. I seem to recall needing them in the past, but I can't seem to recall the implementation...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expression Constructs ?<= and ?=
by davido (Cardinal) on Jan 12, 2006 at 02:11 UTC | |
|
Re: Regular Expression Constructs ?<= and ?=
by ikegami (Patriarch) on Jan 12, 2006 at 02:26 UTC | |
by BrowserUk (Patriarch) on Jan 12, 2006 at 03:08 UTC | |
by diotalevi (Canon) on Jan 12, 2006 at 04:11 UTC | |
|
Re: Regular Expression Constructs ?<= and ?=
by mikeock (Hermit) on Jan 12, 2006 at 15:27 UTC |