From: Kevin Smith Date: 2001-11-23T02:11:32+09:00 Subject: [ruby-talk:26160] Non-perlish regular expressions (was: Linux Magazine article) --- Jos Backus wrote: > On Thu, Nov 22, 2001 at 03:47:43PM +0900, ts wrote: > > J> ($ext) = $mbox =~ /.*?-(.+)$/; > > J> ($ext2) = $ext =~ /.*?-(.+)$/; > > > > /.*?-/ =~ mbox && /.*?-/ =~ (ext = $') && ext2 = $' > > > > Too perlish for me :-(((( > > Yes, thanks Guy, but this looks worse than the Perl > code :) What would be a succinct way to do this in > Ruby I wonder... I know this idiom is used a lot in > Perl. Sorry for jumping in late, and for my ignorance of regular expressions in general, but is this any good? Kevin ---- mbox = '/mailbox/testing-for-dashes' dash_split = Regexp.new('.*?-') ext = dash_split.match(mbox) ext2 = dash_split.match(ext.post_match) ext3 = ext2.post_match p ext.to_s p ext2.to_s p ext3.to_s __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1