Tag: ruby1.9.3

在Ruby 1.9.3中安装debugger-linecache时出错

我需要一个项目的debugger-linecache版本1.0.1,并且在尝试安装时遇到以下错误。 trunk ☺ gem install debugger-linecache -v '1.0.1' Building native extensions. This could take a while… ERROR: Error installing debugger-linecache: ERROR: Failed to build gem native extension. /Users/jordanscales/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for vm_core.h… no checking for vm_core.h… no Makefile creation failed ************************************************************************** No source for ruby-1.9.3-p194 provided with debugger-ruby_core_source gem. ************************************************************************** *** extconf.rb failed *** Could […]

将string转换为正则expression式ruby

我需要像“/ [\ w \ s] + /”string转换为正则expression式。 "/[\w\s]+/" => /[\w\s]+/ 我尝试使用不同的Regexp方法,如: Regexp.new("/[\w\s]+/") => /\/[w ]+\// ,类似于Regexp.compile和Regexp.escape 。 但是他们没有一个像我期望的那样回报。 进一步,我尝试删除反斜杠: Regexp.new("[\w\s]+") => /[w ]+/但没有运气。 然后,我试图做到这一点: str = "[\w\s]+" => "[w ]+" 它逃脱了。 现在,string如何保持原样并转换为正则expression式对象?