From: Daniel Lucraft Date: 2007-06-27T06:51:39+09:00 Subject: Re: oniguruma : can't get it to search for \ (backslash) Dean Holdren wrote: > I can't seem to get Oniguruma to look for a single backslash, am I > doing anything wrong here?: > > I should be able to escape the single with another: > irb(main):043:0> reg = Oniguruma::ORegexp.new('\\') > ArgumentError: Oniguruma Error: end pattern at escape In a regex literal a backslash is a metacharacter, so you need two slashes to match a slash: /\\/ But to insert two consecutive slashes in a string to be compiled into a regex, you need four slashes: "\\\\" Observe: irb> reg = Oniguruma::ORegexp.new('\\\\') => /\\/ best, Dan -- Posted via http://www.ruby-forum.com/.