regex noob question

Using a regular expression, how would I match "howdy" in the
following?

"begin howdy end begin hello end" =~ /begin (.*) end/

match = $1

# current value of match = "howdy end begin hello"

A handy regex tool: http://www.rubular.com

Using a regular expression, how would I match "howdy" in the
following?

"begin howdy end begin hello end" =~ /begin (.*) end/

match = $1

# current value of match = "howdy end begin hello"

Assuming it's that exact string...

>> "begin howdy end begin hello end" =~ /begin (.*?) /; $1
=> "howdy"

But I suspect that won't work for your real usage...

You're right. Unfortunately, that won't work for me. However, the
following will!

>> "begin hi there end begin hello end" =~ /begin (.*?) end/; $1
=> "hi there"

Thanks Philip