Perl extended regexp problems...

Liyang Hu liyang at nerv.cx
Sun Sep 16 04:12:30 CDT 2001


Hi,

    liyang at sakura:~$ echo -e "foobar\ncowbar\ncowmoo" \
        | perl -ne 'print if /(?<!=cow)bar/x'
    foobar
    cowbar
    liyang at sakura:~$

Why?

I've read the FM, and my interpretation of that pattern is ``match
all occurrences of `bar' not immediately prefixed by `cow'.''
Shouldn't the answer be just `foobar'?

How am I supposed to do this? (given the constraint that you've
only got one regex to accomplish the task...)

/Liyang
-- 
.----| Liyang Hu /aka/ DenseBoy |---| http://www.nerv.cx/ |----.
|  Real programs don't eat cache.                              |



More information about the Belfast-pm mailing list