For pure regex I prefer Nathan's approach myself, since I actually find it more 
readable.

One thing to note is that if your Regular Expressions get much more complicated 
than the date example, it might be a sign that you need a different tool.

I've found Treetop really nice for those situations where Regexes get out of 
control.  It's a real grammar, but with familiar regex syntax.

http://treetop.rubyforge.org/

I hope to give a lightning talk on this very topic at the next Sydney RORO.

Josh

On 17/02/2010, at 4:10 PM, Nathan de Vries wrote:

> Hi Paul,
> 
> That's pretty neat if you prefer not to write regular expression syntax. If 
> you're fine with writing regular expressions and you just want to avoid 
> unwieldy blobs of confusion, you can use interpolation like so:
> 
>  http://gist.github.com/306322
> 
> The example is a rewrite of Jim's sample in the README.
> 
> 
> Cheers,
> 
> Nathan
> 
> 
> 
> On 17/02/2010, at 3:01 PM, Paul O'Keeffe wrote:
>> After seeing some difficult  to read, monolithic regular expressions in a 
>> presentation at last week's Ruby meetup in Brisbane, I promised that I would 
>> send a link to a better solution which I vaguely recalled. Here it is:
>> 
>>  http://github.com/jimweirich/re
>> 
>> Jim Weirich library allows you to build up your regular expressions from 
>> smaller pieces, allowing each to be documented and tested separately.
>> 
>> Cheers, Paul.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" group.
> To post to this group, send email to rails-ocea...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rails-oceania+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rails-oceania?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to rails-ocea...@googlegroups.com.
To unsubscribe from this group, send email to 
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to