在Ruby代码中从“abc $ name,efg”中查找“$ name”的正则表达式是什么?

时间:2012-02-29 13:54:29

标签: ruby regex

让我问一下在Ruby代码中从“abc $ name,defg”中找到“$ name”的正则表达式是什么? 有关详细信息,

"$name" must follow the Ruby syntax for global variable names;
I distinguish "$name" from the including text just by "$" at the head 
and a non allowed character for variable names after the tail.

提前谢谢。

1 个答案:

答案 0 :(得分:2)

只需在你的正则表达式上调用match()即可。     /\$name/.m­atch(*yourString*)

相关问题