Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Having a problem with negative look behind assertion

by Athanasius (Monsignor)
on Feb 12, 2013 at 12:41 UTC ( #1018349=note: print w/ replies, xml ) Need Help??


in reply to Having a problem with negative look behind assertion

Just use two regexen:

#! perl use strict; use warnings; while (my $line = <DATA>) { chomp $line; print "$line\n" if $line =~ / [Bb]ar .* \. java $ /x && $line !~ / ^ fee /x; } __DATA__ foo/src/com/stuff/xxxxxx.java foo/src/com/stuff/ggbargg.java foo/src/com/stuff/ggBargg.java fee/src/com/stuff/ggbargg.java fee/src/com/stuff/ggBargg.java

Output:

22:32 >perl 531_SoPW.pl foo/src/com/stuff/ggbargg.java foo/src/com/stuff/ggBargg.java 22:37 >

Hope that helps,

Update: No need for $line:

while (<DATA>) { chomp; print "$_\n" if / [Bb]ar .* \. java $ /x && !/ ^ fee /x; }

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


Comment on Re: Having a problem with negative look behind assertion
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018349]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2014-12-18 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (43 votes), past polls