Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Regex Start Anchor with variables

by jwkrahn (Abbot)
on Oct 05, 2006 at 05:55 UTC ( [id://576473]=note: print w/replies, xml ) Need Help??


in reply to Regex Start Anchor with variables

You probably don't need a regular expression for this:
if ( 0 == index $str1, $str2 ) { print "match\n"; } else { print "nomatch\n"; }
However, if you really want to use a regular expression then you need to escape the meta-characters in $str2:
if( $str1 =~ /^\Q$str2/ ) { print "match\n"; } else { print "nomatch\n"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (None)
    As of 2024-04-25 01:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found