Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 要匹配上次出现的正则表达式_Ruby_Regex - Fatal编程技术网

Ruby 要匹配上次出现的正则表达式

Ruby 要匹配上次出现的正则表达式,ruby,regex,Ruby,Regex,因为我不想再花一个小时搜索正确的正则表达式:我想用gsub删除给定字符串的最后一个反斜杠: "C:\Program Files\".gsub(fancy_regex_here, '') # => "C:\Program Files" 提前感谢您的帮助fancy\u regex\u这里应该是“\\\$”对。这就是要求,虽然没有特别提到。啊,太简单了。非常感谢:-)

因为我不想再花一个小时搜索正确的正则表达式:我想用gsub删除给定字符串的最后一个反斜杠:

"C:\Program Files\".gsub(fancy_regex_here, '') # => "C:\Program Files"

提前感谢您的帮助

fancy\u regex\u这里应该是
“\\\$”

对。这就是要求,虽然没有特别提到。啊,太简单了。非常感谢:-)