in reply to Re: Re: Why do zero width assertions care about lookahead/behind?
in thread Why do zero width assertions care about lookahead/behind?
The way I see it, is that the whole regular expression engine should be able to go either forward or backward. At any point of its execution. To be really able to have variable length look-behind.
is but the beginning. How about:(?<=foo.*?) # if there is a "foo" before the match
<?<=foo.*?(?=.*?bar)) # if there is a "foo" before, with a "bar" afte +r it
To do this properly, you would need to rewrite the whole regex engine, I'm afraid (and what I remember from one of MJD's talks about how he hacked the regular expression engine). This may/will happen for Perl6. So I guess we'll have to hold our breath until then.
Meanwhile, I wonder whether you wouldn't be able to hack something with (?{code}) and/or (??{code}), grabbing the string before the match so far, reversing it and feeding that a reversed regex. Possibly in combination with a source filter.
Hmmm... maybe I shouldn't have these evil thoughts this early in the morning. ;-)
Liz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Why do zero width assertions care about lookahead/behind?
by tilly (Archbishop) on Oct 09, 2003 at 14:16 UTC |