([^("|'|>)])((http(s)?:\/\/|www\.)[A-Z0-9._%+\-\/]*)(?!["|'])
我在以下文字中使用以上内容:
this is the world truning at the ground level https://en.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange this is the world truning at the ground level
this is the world truning at the ground levelthis is the world truning at the ground levelthis is the world truning at the ground levelthis is the world truning at the ground levelthis is the world truning at the ground levelthis is the world truning at the ground levelthis is the world truning at the ground levelthis is the world truning at the ground levelthis is the world truning at the ground levelthis is the world truning at the ground levelthis is the world truning at the ground level http://desktop.com
http://desktop.com http://desktop.com ahsdjhaldhjashdk
如果我在上面的段落中使用此正则表达式,我会获得所有链接,但前面有空格。我需要一个REGEX来检查我所拥有的条件,但选择前面的空格。
我有([^("|'|>)])
的前面检查,如果我需要以下文字:
<a href="http://desktop.com/" target="_blank" data-mce-href="http://desktop.com">http://desktop.com</a>
然后,这里没有任何URL被选中。
答案 0 :(得分:0)
var re = /(?![^<]*>|[^<>]*<\/(?!(?:p|pre)>))((https?:)\/\/[a-z0-9&#=.\/\-?_]+)/gi;
的工作。这可以在a post here。
中找到