我使用的API有时会截断它返回的文本中的链接,而不是"longtexthere https://fancy.link "我得到"longtexthere https:// fa ...".
我只是在完成链接时,或者换句话说不包含"..."字符.
到目前为止,我可以使用以下正则表达式获取链接:
((?:https?:)?\/\/\S+\/?)
Run Code Online (Sandbox Code Playgroud)
但显然它会返回每个链接,包括破碎的链接.
我试过这样的事情:
((?:https?:)?\/\/(?:(?!…)\S)+\/?)
Run Code Online (Sandbox Code Playgroud)
虽然开始忽略"..."字符,但它仍然返回链接,但只是没有包含字符,因此在" https:// fa ..." 的情况下,它返回" https:// fa ",而我只是想要它忽略那个断开的链接并继续前进.
几个小时一直在争吵,只是无法理解它.:(
在此先感谢您的帮助.