我有这个字符串:
<tr onmouseover="setInfo('<b>Details for this (ID:1003030456) on Local</b><br> some more test here:
我想在&#34; ID之间获取数字:&#34;&#34;和#34;)本地&#34;)没有引号。
我有这段代码:
var data = '<tr onmouseover="setInfo('<b>Details for this (ID:1003030456) on Local</b><br> some more test here:';
var result = data.match(/\(ID: (.*)\) on local/);
console.log(result[1]);
但这没有找到它。
如何更改此设置以便找到所需的结果?
答案 0 :(得分:2)
你这里有一些小错误:
'
未转义见这里:
var data = '<tr onmouseover="setInfo(\'<b>Details for this (ID:1003030456) on Local</b><br> some more test here:';
var result = data.match(/\(ID:(.*)\) on Local/);
console.log(result[1]);
&#13;
答案 1 :(得分:1)
ID:
之后的额外空格不在输入
const data = `<tr onmouseover="setInfo('<b>Details for this (ID:1003030456) on Local</b><br> some more test here:`;
const result = data.match(/\(ID:(.*)\) on Local/);
console.log(result[1]);