in reply to Regex: Searching for a string with special characters
I assume by 'brackets' you mean parentheses? That is, '(' and ')'?
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
Try using \Q ... \E in your regular expression if you want to 'escape' the string being searched against:
if ( ! /\Q$search\E/ ) { print "No Match found\n"; next; }
You can find more by reading perlre.
And another option is to use the qr/\Q$search\E/ syntax, which you can find in perlop.
Update: Fixed wording (thanks for pointing that out, Hofmator++.)
Good luck!
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regex: Searching for a string with special characters
by Hofmator (Curate) on Nov 03, 2006 at 10:26 UTC | |
by Anonymous Monk on Nov 03, 2006 at 13:37 UTC |
In Section
Seekers of Perl Wisdom