如何在NODEJS中使用replace?

时间:2018-12-26 06:50:45

标签: javascript jquery node.js reactjs react-native

如何在节点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/

0 个答案:

没有答案