I've this HTML string (validated):
<div><img src="images/stories/2014/AAA.gif" alt="AAA" width="24" height="24" /> THE PRODUCTION OF: PLASTIC BOTTLES <br /></div>
I've to extract the only title near <img>
tag trimming all spaces before and after, than wrap it in a <h1>
tag.
The expeded result should be:
<div><h1>THE PRODUCTION OF: PLASTIC BOTTLES</h1></div>
I've done a regular expression that works but that also include the spaces in the final result:
/<img\s*src="[^"]+"\s*alt="AAA"\s*width="24"\s*height="24"\s*\/>\s*([^<]+)\s*<br\s*\/>/
The image is recognizable for these characteristics values of alt, width and height attributes. Thanks.