Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
but perl requires that <samp>\G</samp> be placed only at the beginning of the regex.if($doc =~ /foo\G/g) { print "position preceeded by foo!\n"; }
One option is to make a substring of the document up to this position, and then just use <samp>$</samp> to mark the end. But this is a large document (all in one scalar) that will be matched this way many times, and string copying is expensive.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Backwards searching with regexps
by chromatic (Archbishop) on Mar 21, 2000 at 23:35 UTC | |
|
Re: Backwards searching with regexps
by jerji (Novice) on Mar 22, 2000 at 00:53 UTC | |
by Anonymous Monk on Mar 22, 2000 at 05:50 UTC | |
by chromatic (Archbishop) on Mar 22, 2000 at 23:06 UTC | |
|
Re: Backwards searching with regexps
by hexram (Initiate) on Mar 22, 2000 at 00:32 UTC | |
|
Re: Backwards searching with regexps
by dlowe (Initiate) on Mar 22, 2000 at 08:10 UTC |