I'm just trying to work on my very first regular expression. I want to be able to map a pseudo HTML element and retrieve useful information such as tag name, attributes, etc .:
$string = '<testtag alpha="value" beta="xyz" gamma="abc" >'; if (preg_match('/<(\w+?)(\s\w+?\s*=\s*".*?")+\s*>/', $string, $matches)) { print_r($matches); }
In addition, I get:
Array ( [0] => [1] => testtag [2] => gamma="abc" )
Does anyone know how I can get other attributes? What am I missing?
php regex
Guillermo Phillips Jul 06 '09 at 15:46 2009-07-06 15:46
source share