From: caleb clausen Date: 2010-01-03T07:33:31+09:00 Subject: [ruby-core:27374] [Bug #2547] error when interpolating a string containing a single backslash into a regexp Bug #2547: error when interpolating a string containing a single backslash into a regexp http://redmine.ruby-lang.org/issues/show/2547 Author: caleb clausen Status: Open, Priority: Normal ruby -v: ruby 1.9.1p376 (2009-12-07 revision 26040) [x86_64-linux] An error is raised if an interpolation in a regexp contains a string containing a single backslash. This case used to work just great in ruby 1.8. For example: $ ruby19 -e 'a="\\"; p /#{a}y/' -e:1:in `
': too short escape sequence (ArgumentError) Note that if the string literal is inlined directly into the interpolation, the error does not happen. I'd guess that ruby optimizes this case away at parse time, and thus sidesteps the error: $ ruby19 -e 'p /#{"\\"}y/' /\y/ I've tested this in 1.9.1; presumably 1.9.2 has the same behavior, but I don't have a 1.9.2 readily available. ---------------------------------------- http://redmine.ruby-lang.org