On Thu, Nov 22, 2001 at 10:20:04AM +0900, Bill Kelly wrote: > > mbox = 'apache-dev-list' > > ext = mbox[/-(.*)/] > > ext2 = ext[/-(.*)/] > > puts "#{mbox},#{ext},#{ext2}" > > > > Fwiw, I was expecting to see > > > > apache-dev-list,dev-list,list > > Might need the "zero width pos/neg look_behind_ assertion" for > that one. :-) Not supported in Ruby yet AFAIK... > > Alternatively, what about: > > x, ext, ext2 = mbox.scan(/[^-]+/) > puts "#{mbox},#{ext}-#{ext2},#{ext2}" Yeah, I came up with x, ext, ext2 = mbox.split('-') to do this. But I'm looking for a replacement in the succinct ($ext) = $mbox =~ /.*?-(.+)$/; ($ext2) = $ext =~ /.*?-(.+)$/; in my Perl code, cookbook-style if you will. So far I haven't been able to come up with an equally short equivalent in Ruby, which of course doesn't mean it can't be done :) One thing I noticed is that the following doesn't work well when there's no match, causing the [1] to fail: ext2 = /.*?-(.+)$/.match(ext)[1] There has got to be an easy way to do this in Ruby. After all, it's trivial in Perl... Thanks, -- Jos Backus _/ _/_/_/ Santa Clara, CA _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ josb / cncdsl.com _/_/ _/_/_/ use Std::Disclaimer;