完全匹配Perl中字符串中包含的$(或特殊字符)开头的单词

时间:2011-03-03 04:23:13

标签: regex perl string

如何从字符串$abc

中精确匹配"this is $$abc abc$abc $abc abc_$abc_ing";之类的字词

1 个答案:

答案 0 :(得分:6)

您可以使用正则表达式:

(\$[a-z]+)

说明:

(        : 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