Largest Regex match possible

In the example below I’d like to match ‘what is’ and ‘foo bar’. Any
ideas?

‘what is foo bar’ =~ /(.)\s(foo bar|bar)/ => 0
$1 => "what is foo "
$2 => “bar”

Thanks!

Hi,

2008/7/23 gsterndale [email protected]:

In the example below I’d like to match ‘what is’ and ‘foo bar’. Any
ideas?

‘what is foo bar’ =~ /(.)\s(foo bar|bar)/ => 0
$1 => "what is foo "
$2 => “bar”

Thanks!

Try this:

‘what is foo bar’ =~ /(.*?)\s+(foo bar|bar)/

Regards,

Park H.

On Jul 23, 1:55 am, Heesob P. [email protected] wrote:

Try this:

‘what is foo bar’ =~ /(.*?)\s+(foo bar|bar)/

Regards,

Park H.

Good stuff. Thanks Park!