From: Joel VanderWerf Date: 2005-08-25T09:28:03+09:00 Subject: Re: regexp character classes and + Mark Volkmann wrote: > On page 71 of Pickaxe 2, discussing character classes, it says "The > significance of special regular expression characters (including +) is > turned off inside the brackets." > > Why is this a valid regular expression (+ not the first character in > the character class) > > %r{^[-+*/]$} > > but this isn't? (+ is the first character in the character class) > > %r{^[+-*/]$} > The - character denotes a range in a regexp. irb(main):001:0> "abc" =~ /[a-c]{3,3}/ => 0 Putting - at the beginning of the bracket expression makes it literal. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407