On 6/13/07, James <[EMAIL PROTECTED]> wrote:
Thanks all, I have something working

> $data =~ s/(.*\n)(?=\1)//g;
Can anyone explain the (?=\1) bit? I get the search replace.

J.

Didn't understand it myself, but see:
http://www.boost.org/libs/regex/doc/syntax_perl.html

Search for Back references

And look at Perl Extended Patterns -> Lookahead
"(?=pattern) consumes zero characters, only if pattern matches."

So... It searches for .*\n and replaces it with "" if there is another
instance of same pattern right after this one.
ie replaces .*\n with "" if it is immediately repeated.

Cool!

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to