From: Tanaka Akira Date: 2008-02-19T16:11:37+09:00 Subject: Re: possible bug in regexp lexing In article <87wsp177pg.fsf@fsij.org>, Tanaka Akira writes: > Not good idea. > > % ./miniruby -ve 'p %r{\}}' > ruby 1.8.6 (2008-02-05 patchlevel 5000) [i686-linux] > -e:1: warning: regexp has `}' without escape > /}/ More problems: % ./miniruby -e 'p %r(\))' -e:1: unmatched ): /)/ % ./miniruby -e 'p %r|\|| =~ "a"' 0 % ./miniruby -e 'p %r?\??' -e:1: invalid regular expression; there's no previous pattern, to which '?' would define cardinality at 1: /?/ In general, adding/removing a backslash is not safe for meta characters. Note that %r%/%.source is "/". However p %r%/% prints /\//. The backslash in /\// is added by Regexp#inspect. It is safe because a slash is not a meta character for regexp engine. -- Tanaka Akira