From: Chad Perrin Date: 2007-03-11T06:46:25+09:00 Subject: Re: A couple of questions from a Ruby neophyte On Sun, Mar 11, 2007 at 05:17:24AM +0900, Brian Candler wrote: > On Sun, Mar 11, 2007 at 04:42:19AM +0900, Chad Perrin wrote: > > > This is probably a FAQ, but just how different *are* Perl and Ruby regex > > > capabilities? I'm not a heavy regex user by any stretch of the > > > imagination. I do the basic stuff that will work anywhere (original > > > "vi", "grep", "sed", "awk") so Perl and Ruby are overkill for me. > > > > For the most part, they're pretty similar. There are a few differences > > that can trip you up, though -- for instance, in Ruby this works for > > matching either foo or bar: > > > > /foo|bar/ > > > > . . . whereas in Perl you'd need to do this: > > > > /(foo|bar)/ > > Really? > > $ perl -e '$_ = "abcfoodef"; print "match!\n" if /foo|bar/' > match! > $ perl -v | head -3 > > This is perl, v5.8.7 built for i486-linux-gnu-thread-multi > (with 1 registered patch, see perl -V for more detail) Wow. All this time, I thought the parentheses were necessary. Funny. Thanks for disabusing me of that notion. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] "Real ugliness is not harsh-looking syntax, but having to build programs out of the wrong concepts." - Paul Graham