I have a random, long string of html code (user-entered) - I need to check it for img tags and the respective widths/heights and replace every image instance with a string of proprietary code, so for example
Hello world <img src="http://example.com/image.jpg" width="320" height="240" /> this is some random text <img src="http://example.com/cutepuppy.jpg" width="150" height="200" />
Needs to be replaced with
Hello world [img:http://example.com/image.jpg w:320 h:240] this is some random text [img:http://example.com/cutepuppy.jpg w:150 h:200]