Re: oniguruma : can't get it to search for \ (backslash)
- From: Daniel Lucraft <dan@xxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Jun 2007 06:51:39 +0900
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/.
.
- References:
- oniguruma : can't get it to search for \ (backslash)
- From: Dean Holdren
- oniguruma : can't get it to search for \ (backslash)
- Prev by Date: Re: Class instance into included module
- Next by Date: Re: Following a Javascript Link Using Mechanize
- Previous by thread: oniguruma : can't get it to search for \ (backslash)
- Next by thread: Fun about inspect
- Index(es):
Relevant Pages
|