js regular matching img image tag containing a certain attribute

For example, if I want to match an img that contains a class attribute, and get the value of the class, whether it is regular or not, it starts with <img and ends with />, contains the class attribute in the middle, and ignores other attributes in the middle.

<img alt="HD" id="av" src="a.jpg"'/>

 

The answer is as follows:

<img.*?class="(.*?)".*?\/?>

 

Guess you like

Origin blog.csdn.net/t1174148618/article/details/107598235