让我问一下在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.
提前谢谢。
答案 0 :(得分:2)
只需在你的正则表达式上调用match()
即可。
/\$name/.match(*yourString*)