I can use /[?%.]/ to search the string which contains those character, but how I can search some characters such as "/", "$" etc..., anyone can help me?
print "matched" if $string =~ /\$/; # -> matched
The backslash before a character tells Perl that the character following the backslash is to be interpreted:
1) as a special character, if it is otherwise normal
2) as a normal character (literal), if it is otherwise special.
If you are matching a bunch of funny characters, use the \Q and \E patter characters like so:
$string =~ /\Q$funny.characters-*&here\E/;
And the funny characters in between the \Q and the \E will be matched literally.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.