开发者

match exactly a word starting with $( or special character)contained in a string in Perl

开发者 https://www.devze.com 2023-02-14 07:13 出处:网络
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:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消