From: Robert Klemme Date: 2003-06-13T21:33:25+09:00 Subject: Re: Question on regexp "John Johnson" schrieb im Newsbeitrag news:BB0F29BC.4DEC%jj5412@earthlink.net... > on 6/13/03 6:32 AM, Robert Klemme at bob.news@gmx.net wrote: > I have a function I'm using now has_both(string, regexp1, regexp2) which I > use in an if statement, then I go back and extract the value(s). I was > hoping there was a RegExp that matched two words so I could put everything > into a nice case/when statement. You can do that: conf=< I suppose there isn't, though. Well, you can do that, but you need to have n! alternatives for n words: conf.each do |line| if ( m = /(\blines\b.*\blabel\b|\blabel\b.*\blines\b).*\b(\d+)\b/.match( line ) ) puts "label lines=#{m[2]}" end end I'm not sure which of the two variants (one regexp vs. n regexps) is more efficient. I guess you will hit some limit if n becomes larger. > Thanks again! You're welcome. Regards robert