From: Simon Baird Date: 2006-07-28T10:10:56+09:00 Subject: Equivalent of perl's \Q in regexps? ------=_Part_276515_25553695.1154049052726 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline marker = '***' code = <<-EOT var x = 1 //*** hello function foo() {} EOT p code.to_a.grep(/\*\*\*/) # -> ["//*** hello\n"] that's what I want but using marker #p code.to_a.grep(/#{marker}/) # -> invalid regexp error p code.to_a.grep(/#{%q(marker)}/) # -> [], doesn't work In perl you can do /\Q$marker/ and it escapes $marker for the regexp. Simon. -- Simon Baird ------=_Part_276515_25553695.1154049052726--