0

I have a tag <a href="#caveat1"><span style="color: rgb(255,255,255);">[1]</span></a>

I am using this regex <a href="(.*)">(.*)<\/a> But its not parsing the url only. Its also parsing <span style="color: rgb(255,255,255);">[1]</span>

How can i get only the url from a tags?

4

1 回答 1

0

容易地!捕获介于href(即关键字)和之间的所有内容<

href=(.*?)>

如果你不想捕获"",试试这个:

href="(.*?)">

虽然我对 node.js 没有太多经验,但我认为这个可能有用,但如果你知道 Regex,这对你来说并不难。

var pattern = new RegExp(/href="(.*?)">/);

这是Regex101

于 2016-03-16T14:17:23.137 回答