From: Brian Candler Date: 2003-04-08T00:41:20+09:00 Subject: Re: ruby-dev summary 19944 - 19957 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... Regards, Brian.