I'm just trying my hand at crafting my very first regex. I want to be able to match a pseudo HTML element and extract 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);
}
Except, I'm getting:
Array ( [0] => [1] => testtag [2] => gamma="abc" )
Anyone know how I can get the other attributes? What am I missing?