Re: [rails-oceania] Readable regular expressions

2010-02-21 Thread David Lee
+1 Nathan, Lachie. To me the 're' lib looks like a new syntax and another layer of indirection, which is likely going to be more, rather than less, work to figure out than a well-written vanilla regexp ... On Wed, Feb 17, 2010 at 7:17 PM, Mikel Lindsaar wrote: > On Wed, Feb 17, 2010 at 4:48 PM,

Re: [rails-oceania] Readable regular expressions

2010-02-17 Thread Mikel Lindsaar
On Wed, Feb 17, 2010 at 4:48 PM, Nathan de Vries wrote: > I seem to remember that when I worked with TMail a couple of years back, > addresses were checked for RFC2822 compliance using a regular expression. > Despite being broken up into readable chunks like my example, it was still > far too c

Re: [rails-oceania] Readable regular expressions

2010-02-16 Thread Lachie
I'm a fan of extended mode regexes http://gist.github.com/306355 admittedly, often OTT Another (good?) complex regex example is in URI, in uri/common.rb, part of the stdlib. Its a line by line translation from the URI RFC's BNF. :lachie On Wed, Feb 17, 2010 at 5:12 PM, Josh Price wrote: > On

Re: [rails-oceania] Readable regular expressions

2010-02-16 Thread Josh Price
On 17/02/2010, at 4:43 PM, Chris Lloyd wrote: > On 17 February 2010 16:23, Josh Price wrote: > I hope to give a lightning talk on this very topic at the next Sydney RORO. > > Lightning talk on Treetop? I'm sure you could fill a full talk ;) A full talk and more! However I plan to do a short in

Re: [rails-oceania] Readable regular expressions

2010-02-16 Thread Nathan de Vries
Hi Josh, I seem to remember that when I worked with TMail a couple of years back, addresses were checked for RFC2822 compliance using a regular expression. Despite being broken up into readable chunks like my example, it was still far too complex to read & modify. Looking at the new Mail gem, i

Re: [rails-oceania] Readable regular expressions

2010-02-16 Thread Chris Lloyd
On 17 February 2010 16:23, Josh Price wrote: > I hope to give a lightning talk on this very topic at the next Sydney RORO. Lightning talk on Treetop? I'm sure you could fill a full talk ;) -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" gr

Re: [rails-oceania] Readable regular expressions

2010-02-16 Thread Josh Price
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

Re: [rails-oceania] Readable regular expressions

2010-02-16 Thread Nathan de Vries
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

[rails-oceania] Readable regular expressions

2010-02-16 Thread Paul O'Keeffe
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 u