Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: String Match

by bellaire (Hermit)
on Nov 30, 2009 at 12:28 UTC ( [id://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
    Almost.
    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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-25 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found