From: Jos Backus Date: 2001-11-23T13:58:47+09:00 Subject: [ruby-talk:26195] Re: regex/split/scan question (was: Re: Linux Magazine article) On Fri, Nov 23, 2001 at 01:36:21PM +0900, Dave Thomas wrote: > ext, ext2 = /-(.*?-(.*))/.match(mbox).to_a[1,2] > > That's fairly succinct :) Yes, but it but it breaks on things like irb(main):007:0> ext, ext2 = /-(.*?-(.*))/.match('apache-dev').to_a[1,2] [nil] What I am looking for is an expression that returns a String instead of an Array, so I can do this in two steps (just like the Perl version): irb(main):018:0> ext = /-(.*)/.match('apache-dev-list').to_a[1,2].pop "dev-list" is almost what I want except when it doesn't match: irb(main):019:0> ext = /-(.*)/.match('apachedevlist').to_a[1,2].pop NameError: undefined method `pop' for nil from (irb):19 irb(main):020:0> Thanks, -- Jos Backus _/ _/_/_/ Santa Clara, CA _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ josb@cncdsl.com _/_/ _/_/_/ use Std::Disclaimer;