I have a string, in javascript, containing a few img tags.
I need to find those who don't have a class property and add a class named "myClass" (class="myClass") img tags that already have a class - I should not touch.
note that this is not DOM so I can't use things like "element.classList.contains(class)" which would be very helpful for that.
I can only use regex. and again, the string can contain more than 1 img tag.
example string:
<img src="https://google.com/animage.jpg" class="google">
<img src="https://yahoo.com/animage.jpg">
this is what I use to find img tags in the string that DO have a class property:
<\s*\/?\s*img[^>]* class=[^>]*>
what regex should I use to find those who don't and add a class only to those?
would be best if I could just use thsoe img tags as if they are part of the DOM but I can't I also can't use jQuery by the way
edit: I should mention that the string contains not only img tags but other tags and other HTML content as well.