I'm trying to understand these regular expressions, but I can't make them
work...

All I want to do, is to find the first occurrence of some text inside the
HTML tags <h1> and </h1>.

Example string: "<p>October 14, 2006</p><h1>Welcome to my
homepage</h1><p>We're happy to announce...</p>"

must return:

"Welcome to my homepage"


I tried with:

preg_match('<h1\b[^>]*>(.*?)</h1>', "<h1>Welcome to my homepage</h1>",
$matches, PREG_OFFSET_CAPTURE);
print_r($matches);

but got nothing...

Can anyone tell me how to do this?

(I tried the above expression in EditPad Pro 6 and it worked...!)

Sincerely,

Morten Twellmann

Reply via email to