有人可以帮我弄清楚我的图案有什么问题吗?
这是我的文字:sid ='206'x = '34 .8395'y = '32 .1178'>×2(206)
var regex = new RegExp("/x=\'[0-9]+\.[0-9]+\' y=\'[0-9]+\.[0-9]+\'/");
var match;
do {
match = regex.exec(text);
if (match) {
console.log(match[1], match[2], match[3], match[4]);
}
} while (match);
RegExp
构造函数中没有定界符。
您可以使用此正则表达式:
var re = /x='(\d+\.\d+)' +y='(\d+\.\d+)'/g;
var str = "sid=\'206' x='34.8395' y='32.1178'>×2 (206)";
while ((m = re.exec(str)) != null) {
console.log(match[1], match[2]);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句