我有以下字符串,HTML标记内有双引号。
Have a "question" about xyz Web? <a href="https://xyz/yasd/aksda">Save time</a> before you get in touch with us.
我想删除双引号,只要它存在于字符串内的HTML标记中。 我尝试了多个正则表达式但没有找到符合此要求的正则表达式。
尝试了
var str = "parag here "aman" <br style = 'width:100px'/> test link<a href=\"http://www\"></a>";
var regex = /<\w+\s*(\w+\s*=\s*(['][^']*['])|(["][^"]*["]))*\s*[\/]?>/g;
var rstr = str.replace(regex, function($0,$1,$2){
return $0.replace($2, $2.replace(/'/g, '"'));
});
预期输出为:Have a "question" about xyz Web? <a href='https://xyz/yasd/aksda'>Save time</a> before you get in touch with us.