I'm looking to get only the style attribute and it's contents using regex in php.
For example
Input
<img src="test.png" style="float:left;"/>
Desired Output
style="float:left;"
What i've tried:
This seems to return the entire image, and i'm not sure why. I suck at regex.
$img = '<img src="test.png" style="float:left;"/>';
preg_match('/(<[^>]+) style=".*?"/i', $img, $match);
Returns:
[0] => Array
(
[0] => <img src="test.png" style="float:left;"
[1] => <img src="test.png"
)
Anyone with any pointers?
Cheers.