From: Ken Bloom Date: 2006-12-07T14:00:11+09:00 Subject: Re: Why is this regex invalid? On Thu, 07 Dec 2006 01:24:30 +0100, David Kastrup wrote: > Christopher Schneider writes: > >> I'm pretty sure the dash needs to be escaped in regular expressions. >> The second one works since it is the last character in the character >> class, and hence isn't defining a range. >> >> /([0-9]*)([^\+\- ]+)(.*)/ should work - note the escaped dash. > > Rubbish. In character ranges, \ is not special. It most certainly is special: irb(main):014:0> /[a\+\- ]/=~".\\" => nil -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/