Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Stupid question about strings...

by davido (Cardinal)
on Jul 14, 2014 at 08:32 UTC ( [id://1093514]=note: print w/replies, xml ) Need Help??


in reply to Stupid question about strings...

The | character is a metacharacter, and if it exists in $str2, it is being interpreted as alternation. You probably want something like this:

if( $str1 =~ m/\Q$str2/gi ) { ...

Dave

Replies are listed 'Best First'.
Re^2: Stupid question about strings...
by AnomalousMonk (Archbishop) on Jul 14, 2014 at 11:55 UTC
    if( $str1 =~ m/\Q$str2/gi ) { ...

    The use of the  /g modifier is meaningless in this context, although it does no harm.

Re^2: Stupid question about strings...
by kepler (Scribe) on Jul 14, 2014 at 08:45 UTC
    Ok....I was being stupid..... Thank you very much for the help :) Kind regards, Kepler

      Not stupid. It's an easy mistake to make. By the way; I like the index option mentioned later in the thread better if your search string is just a string and not a pattern.


      Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-03-19 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found