Hi,
I'm working on a regular expression pattern to extract tag and attributes from an html element. But I have some problems with matching the attributes :s. Only the last attribute is stored into the matches array.
Here is the code:
<?php
$subject = '<font face="arial" size="1" color="red">hello world!</font>';
$find= '/<(?P<tag>\w+)\s+((?P<attr>\w+)=(?P<value>[^\s""\'>]+|"[^"]*"|\'[^\']*\')\s*)*\/?>/si';
preg_match_all( $find, $subject, $matches );
?>
Can someone help me out?
Many thanks