From: Marnen Laibow-Koser Date: 2010-01-14T02:49:20+09:00 Subject: Re: Ruby Regex Gary Wright wrote: > On Jan 13, 2010, at 10:56 AM, Marnen Laibow-Koser wrote: >> >> ...and Ruby's stupid backslash handling strikes again. This is a >> completely brain-dead way to do it, and is one of the few things I >> really hate about Ruby. > > Is this really a Ruby snafu? Yes. The problem is that Ruby "helpfully" does another level of escaping, so that "\\&" is equivaIent to "\&", whereas it should simply take the escape at face value and consider it equivalent to the two characters \ and &. For real fun, try concatenating two strings, the first of which ends in a backslash. It's insane. > It seems like it would be inherent in > any sort of character escape sequence, of which there are many > examples that have nothing at all to do with Ruby. > But Ruby has its own special brand of idiocy here. Even Perl and PHP get this right. > Any pointers to alternative encoding schemes that avoid this problem? It has nothing to do with encoding. It's a question of a particular point of stupidity in Ruby's parser and/or String class. > > > Gary Wright Best, --  Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.