Article From:https://segmentfault.com/q/1010000012151020
Question:

For example, the following code: < span> 13818888778< /span> 1381888778
How do I use regular matches to take only the numbers other than the span tag instead of the numbers inside the span tag?

Answer 0:
var res ='<span>13818888778</span>1381888778'.match(/<span.*?\/span>(\d+)$/);
console.log(res[1])
//Output 1381888778

Answer 1:
// </span>All in the back is the number?/ / Programme 1Let STR ='< span> 13818888778< /span> 1381888778';Let result = /< span> \w*< \/span> (\d*) /.exec (STR);Console.log (result[1]); / /'1381888778'/ / / scheme two string interceptionStr.slicE (str.lastIndexOf ('< /span> ') +7, str.length)/ / 1381888778

Leave a Reply

Your email address will not be published. Required fields are marked *