如何在节点js中使用替换?
HTML:
<p> <a href="https://www.abc.co/">https://www.abc.co/</a> Lorem ipsum dolor sit amet, praesent justo sem suscipit dolor,<a href="https://www.abc.co/">https://www.abc.co/</a> maecenas pellentesque ligula vestibulum in vivamus eu </p>
我尝试:
const variableabc = document.getElementsByTagName('p');
const result = variableabc.replace('/(https?:\/\/[^\s]+)/g','<a href="$1">$1</a>');
预期输出:
https://www.abc.co/
https://www.abc.co/