Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Negative expressions with alternation in ProxyRemoteMatch

by Roger (Parson)
on Aug 30, 2005 at 06:50 UTC ( #487657=note: print w/replies, xml ) Need Help??

in reply to Negative expressions with alternation in ProxyRemoteMatch

Try negative look ahead.

my @str = qw/ a.jpg b.gif c.png d.txt e.jpeg a.jpg.3 /; for my $str (@str) { if ($str =~ /.*?\.(?!gif|jpe?g)/) { print "matched: $str\n"; } } __END__ # output is matched: c.png matched: d.txt matched: a.jpg.3

Replies are listed 'Best First'.
Re^2: Negative expressions with alternation in ProxyRemoteMatch
by redhotpenguin (Deacon) on Aug 30, 2005 at 07:21 UTC
    Thanks for the help, this is what I was trying to do. Works great, and it makes sense that the '?!' (whabang?) is at the start of the alternation.
      An alternative is to use negative look behind... Your code was actually negative look ahead. To look behind, you need the < directive.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://487657]
[james28909]: Good morning!
[james28909]: I have a problem I am trying to solve. I am packaging scripts using pdk and would like the verify the executable name each time it is executed
[Corion]: Hi James!
[james28909]: I looked through the docs, and see that PerlApp::exe() is suppose to return this information but whenever i try to use this, i get the error "Undefined subroutine &PerlApp::exe called"

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2017-07-28 13:47 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (429 votes). Check out past polls.