From: Eric Mahurin Date: 2008-02-06T23:46:18+09:00 Subject: Re: Parsing JSON (#155) ------=_Part_15838_468867.1202309181590 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Feb 6, 2008 2:05 AM, tho_mica_l wrote: > > I think the benefit of Regexp goes down the more of them you are using. > > They are a convenient solution for a wide range of problems. You are taking my statement out of context. I was referring to performance. If you are using a bunch of little regex's, you won't see much performance benefit compared to matching a character at a time with a 1 character lookahead (LL(1) parsing). I think you can write a pure ruby LL(1) lexer/parser that usually meets or beats a regex version. But yes, using regex's are are convenient for a wide range of problems. With respect to extending ruby's regexp, I'd rather be interested in > embedded code snippets that are evaluated when a clause matches. I > didn't know perl (http://perldoc.perl.org/perlre.html) does this until > I read about it in the ragel manual. It seems there are two kinds of > embedded code: (1) evaluate the code and match with null width; (2) > use the return value of the code as regexp. This sound quite > interesting to me. It's currently listed under "A-3. Lacked features > compare with perl 5.8.0" in the ruby RE manual. > Yep. I used this in perl 5+ years ago (before coming to ruby) to write recursive regex's (i.e. paren matching). But, this doesn't address the issue I was referring to - applying a Regexp to something other than a String. ------=_Part_15838_468867.1202309181590--