且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正则表达式在文本中找到url

更新时间:2023-02-25 16:15:03

你不能用正则表达式完美地做到这一点。您可能对此博客文章感兴趣。有关 Regex Guru ,但即使那些看起来非常脆弱。您需要在正则表达式之外进行额外的检查以捕获边缘情况。

You can't do this perfectly with a regular expression. You may be interested in this blog post. There is a bit more information on Regex Guru, but even those look very fragile. You will need to have additional checks outside of your regular expression to catch the edge cases.