I have a html string:
<p>1</p> <p><img src="/filename.jpg" /></p>
<p>2</p> <p><img src="/filename.jpg" alt="1324" width="600" height="180" /></p>
<p>3</p> <p><img style="border-width: 1px;" src=/filename.jpg" alt="" width="1000" height="300" /></p>
<p>4</p> <p><img style="border-width: 1px; max-width:100%" src=/filename.jpg" alt="" width="1000" height="300" /></p>
I need to search for all img tags in this string. If it doesn't have that property, insert style="max-width:100%" as an attribute to them. If that img tag already has the style attribute, then I need to add property "max-width:100%". I use Java.
How to accomplish this?