Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: String Match

by bellaire (Hermit)
on Nov 30, 2009 at 12:28 UTC ( #810137=note: print w/replies, xml ) Need Help??

in reply to String Match

You don't need quotes inside the regex (the paired slashes do that job), including them searches for quotes inside your string, which you don't have. That makes:
if($line =~ m/API#/) { ...
UPDATE: Thanks for the replies, as ww indicates, you actually want to negate the search on the second # symbol, as his solution does (see below).

Replies are listed 'Best First'.
Re^2: String Match
by ww (Archbishop) on Nov 30, 2009 at 13:06 UTC
    if($line =~ m/API#[^#]/) { ...

    The negative character class makes the regex reject the doubled-#, as per OP's question.

    Update: Better answer below at Re^3: String Match. ++ happy.barney!

      better is to use negative look around assertion: m/API#(?!#)/, it match also end of line.
Re^2: String Match
by zeni (Beadle) on Nov 30, 2009 at 13:03 UTC
    This din't solve the problem. It says "Matched".

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2019-10-22 12:24 GMT
Find Nodes?
    Voting Booth?