From: Robert Klemme Date: 2011-02-17T18:53:12+09:00 Subject: Re: regex simplifier? On Thu, Feb 17, 2011 at 12:22 AM, Roger Pack wrote: >> %r{(?#{float})#{whitespace}(?[+-])#{whitespace}(?#{float})i} >> >> But the kicker is still how to remember that \s is white space, not \w. >> And we've been forced to do some tip toeing around the complexities of >> regex in order to make it readable. >> >> I had thought of a regex creator helper >> >> float = reg { optional(/[-+]/) + 'DIGIT+ \. DIGIT+' } > > I just found something related, for followers: > > posix characters are apparently embedded in there: > > [:blank:] > > like >>> ' a '.scan /[[:blank:]]/ > => [" ", " "] >>> ' a '.scan /[^[:blank:]]/ > => [" ", " "] > > ref: http://psoug.org/reference/regexp.html > > Though I still wouldn't be averse to something like > Regexp::DIGIT => '\d' > > So one can do "#{Regexp::DIGIT}*" Did I mention that what Ari and I cooked up a while ago is a gem? http://rubygems.org/gems/TextualRegexp Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/