Reputation:
I have got this string:
<tr onmouseover="setInfo('<b>Details for this (ID:1003030456) on Local</b><br> some more test here:
I am trying to get numbers between "ID:"" and ") on Local" without the quotes.
I had this code:
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]);
But this is not finding it.
How can I change this so it finds the result required?
Upvotes: 0
Views: 31
Reputation: 97227
ID:
that is not in the inputconst 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]);
Upvotes: 1
Reputation: 6151
You have small mistakes here:
'
in your string was not escapedsee here:
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]);
Upvotes: 2