Regular match <img src= "https:/XXX.jpg" style= "" >

problem description

https:/XXX.jpg" ; style=" width:999px; ">
https:/XXX.jpg" ; style= "width:999px;" data-id= "1" >
results obtained by regular matching
https:/XXX.jpg" ; finally, only src attributes are retained, and no other attributes are left

.

the environmental background of the problems and what methods you have tried

because the format of the string tag style obtained from the background is standard, which is
, style=" width: "999px". "data-id=" 1 ">
causes matching errors to garble
attempts to configure with non -, but the result is, for example," / < sup id= "fnref-1" > https://img.codeshelper.com/upload/img/2022/02/14/f03gfn5teju3147 https://api-v5.segmentfault.com/question/"- sharpfn-1" class= "footnote-ref" > 1 < / sup > / g "means non-h, non-e, non-l non-o, does not mean non-(hello), so the matching result is w and rd123.
so it"s not the effect I want

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

https:/XXX.jpg" ; finally, only the src attribute is retained, and no other attributes are left

< hr >
    < li id= "fn-1" > hello https://img.codeshelper.com/upload/img/2022/02/14/f03gfn5teju3147 https://api-v5.segmentfault.com/question/"- sharpfnref-1" class= "footnote-backref" > please
Feb.14,2022

the purpose of conciseness is to intercept src content, and then build img with src content

function re(str) {
    var match = (str || '').match(/src=("|')(.+?)\1/);
    if(!match) {
        return false;
    }
    return "<img src='" + match[2] + "'/>"
}

the premise is that your symbols are correct, the double quotation marks between attributes are symmetrical, and " is converted to quotation marks

.
var reg =/\<img.+(src=\".+?")([^>]+)?\>/;
str.replace(reg,<img $1>);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b416ec-2c579.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b416ec-2c579.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?