Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: regexp matching with "\[" in the substring to be matched

by nobull (Friar)
on Jul 05, 2005 at 16:39 UTC ( [id://472514]=note: print w/replies, xml ) Need Help??


in reply to regexp matching with "\[" in the substring to be matched

$p="horraen=sumsel\[13\]\)\n"; $m="sumsel\[13\]";

The above are exactly equivalent to

$p="horraen=sumsel[13])\n"; $m="sumsel[13]";

If you really want backslashes in the strings you need to double them or use single quotes.

$p="horraen=sumsel\\[13\\]\\)\n"; $m="sumsel\\[13\\]";
..or..
$p='horraen=sumsel\[13\]\)' . "\n"; $m='sumsel\[13\]';

Actually since $m is a regex it's more ideomatic to use qr// unless there's a reason you can't. Also I don't think you really wanted backslashes in $p.

$p="horraen=sumsel[13])\n"; $m=qr/sumsel\[13\]/;

Log In?
Username:
Password:

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

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

    No recent polls found