match exactly a word starting with $( or special character)contained in a string in Perl
how do i exactly match a word like $abc
from a string "this i开发者_运维问答s $$abc abc$abc $abc abc_$abc_ing";
You can use the regex:
(\$[a-z]+)
Explanation:
( : Start of group
\$ : A literal $. Since $ is a metacharacter we escape it.
[a-z]+ : one or more letters that is a word. You can use the modifier i
to match uppercase letters aswell.
) : End of grouping
精彩评论