Questions tagged «ruby-1.9.3»

5
将字符串转换为正则表达式ruby
我需要将“ / [\ w \ s] + /”之类的字符串转换为正则表达式。 "/[\w\s]+/" => /[\w\s]+/ 我尝试使用不同的Regexp方法,例如: Regexp.new("/[\w\s]+/") => /\/[w ]+\//,类似Regexp.compile和Regexp.escape。但是他们都没有得到我所期望的回报。 我还尝试了删除反斜杠: Regexp.new("[\w\s]+") => /[w ]+/ 但是没有运气。 然后,我尝试使其变得简单: str = "[\w\s]+" => "[w ]+" 它逃脱了。现在如何将字符串保持原样并将其转换为regexp对象?
117 ruby  regex  string  ruby-1.9.3 

9
红宝石调试与Ruby 1.9.3?
我刚刚更新到Ruby 1.9.3p0和Rails 3.1.1。现在,当我尝试启动服务器时,它抱怨我应该安装ruby-debug,即使它已经安装了。 % rails server --environment=development --debug => Booting WEBrick => Rails 3.1.0 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug' Exiting …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.