The picture shown is an html string. Is there any way to get the content in the red box?
var dom = $('a').clone(); dom.find('i,button').remove(); console.log(dom.html());
Provide an idea to use regular expressions to match tag segments...
First get the dom of the a tag Then find the node whose nodeName is '#text' from the a.childNodes array and get the nodeValue.
You can refer to my answer to this question, the idea is the same: /q/10...
Also attached is a method to convert code strings into DOM: https://stackoverflow.com/que...
var code = '<li>text</li>'; var p = document.createElement('p'); p.innerHTML = code; var elements = p.childNodes;
If it can be converted into a DOM object, use javascript; if it can only use strings, use regular matching.
Provide an idea to use regular expressions to match tag segments...
First get the dom of the a tag
Then find the node whose nodeName is '#text' from the a.childNodes array and get the nodeValue.
You can refer to my answer to this question, the idea is the same:
/q/10...
Also attached is a method to convert code strings into DOM:
https://stackoverflow.com/que...
If it can be converted into a DOM object, use javascript; if it can only use strings, use regular matching.