Javascript 使用正则表达式提取值
我的字符串是:'input type=“hidden”value=“5999”id=“productPrice”' 我想从这个字符串中提取值。请帮我为此编写正则表达式。Javascript 使用正则表达式提取值,javascript,regex,Javascript,Regex,我的字符串是:'input type=“hidden”value=“5999”id=“productPrice”' 我想从这个字符串中提取值。请帮我为此编写正则表达式。var string=''; var string = '<input type="hidden" value="5999" id="productPrice">'; var regex = /<input type="hidden" value="([^"]+)" id="productPrice"/gi;
var string='';
var string = '<input type="hidden" value="5999" id="productPrice">';
var regex = /<input type="hidden" value="([^"]+)" id="productPrice"/gi;
var price = regex.exec(string);
console.log(price[1]);
price[1];
var regex=/我知道我不想把头撞到墙上去检查这一点。不需要正则表达式,只需使用DOM即可。