From: El Gato Date: 2007-02-01T04:34:00+09:00 Subject: Re: Regexp captures Robert Klemme wrote: > > Yes. Use String#[]: > > your_match = result[/id: (\d+)/, 1] || result[/error: (.*)/, 1] > > Note: your second part "result.scan" will always return at most one > match because of ".*". That's the reason why a single match like mine > yields the same output. > > Other alternatives: > > This one is more interesting if you extract different portions of the > match: > > > But I'd prefer the first variant. :-) > > Kind regards > > robert Wow! Thanks a bunch Robert. I had never seen String#[] before. That's a lot cleaner than my version. I appreciate the help and input from both of you. -- Posted via http://www.ruby-forum.com/.