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/.