Regular expressions

From: Date: Sat, 14 Oct 2006 21:19:13 +0000
Subject: Regular expressions
Groups: php.general 
Request: Send a blank email to php-general+get-243148@lists.php.net to get a copy of this message
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

« previous php.general (#243148) next »