From: ahoward Date: 2003-04-08T01:28:47+09:00 Subject: Re: ruby-dev summary 19944 - 19957 On Tue, 8 Apr 2003, Brian Candler wrote: > On Tue, Apr 08, 2003 at 12:20:40AM +0900, Kazuo Saito wrote: > > They plan to change the regexp parsing rule in 1.8.0 as follows so far. > > The plan is based on regexp coding conventions and requests from others > > in ruby-dev: > .. > > 2) A literal '-' in a character class should be escaped too if the > > class has other '-' literals for range representation. For instance, > > /[abcd-f-hijk]/ and /[--abc]/ should be written as > > /[abcd-f\-hijk]/ (or /[abcd\-f-hijk]/) and /[\--abc]/. > > You can use '-' without '\' if the class has no ranges, like > > /[-abc]/ or /[^-]/. > > The way I parse regexps in my brain is the way I have been conditioned > through what I have learned with grep, awk, perl and so on :-) > > I often use character classes like this: > > /[a-zA-Z0-9.-]/ > > which matches a-z, A-Z, 0-9, dot or dash. This is how it works everywhere > else. The rule is 'if you want to match a dash, put it at the very beginning > or very end of your character class' > > I can't see any particular reason to outlaw this practice... i'm with brian on this - those of us who've been converting old lex/perl parsers to ruby have enough trouble saving the regexes people took hours to write. backward compatibility in something as arcane as regexes is not just nice - it's essential. -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================