可以试试这个:
\b(?:(?:https?|ftp|file)://|www\.|ftp\.)[-A-Z0-9+&@#/%=~_|$?!:,.]*[A-Z0-9+&@#/%=~_|$]
解释
<!--
\b(?:(?:https?|ftp|file)://|www\.|ftp\.)[-A-Z0-9+&@#/%=~_|$?!:,.]*[A-Z0-9+&@#/%=~_|$]
Options: case insensitive
Assert position at a word boundary «\b»
Match the regular expression below «(?:(?:https?|ftp|file)://|www\.|ftp\.)»
Match either the regular expression below (attempting the next alternative only if this one fails) «(?:https?|ftp|file)://»
Match the regular expression below «(?:https?|ftp|file)»
Match either the regular expression below (attempting the next alternative only if this one fails) «https?»
Match the characters “http” literally «http»
Match the character “s” literally «s?»
Between zero and one times, as many times as possible, giving back as needed (greedy) «?»
Or match regular expression number 2 below (attempting the next alternative only if this one fails) «ftp»
Match the characters “ftp” literally «ftp»
Or match regular expression number 3 below (the entire group fails if this one fails to match) «file»
Match the characters “file” literally «file»
Match the characters “://” literally «://»
Or match regular expression number 2 below (attempting the next alternative only if this one fails) «www\.»
Match the characters “www” literally «www»
Match the character “.” literally «\.»
Or match regular expression number 3 below (the entire group fails if this one fails to match) «ftp\.»
Match the characters “ftp” literally «ftp»
Match the character “.” literally «\.»
Match a single character present in the list below «[-A-Z0-9+&@#/%=~_|$?!:,.]*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
The character “-” «-»
A character in the range between “A” and “Z” «A-Z»
A character in the range between “0” and “9” «0-9»
One of the characters “+&@#/%=~_|$?!:,.” «+&@#/%=~_|$?!:,.»
Match a single character present in the list below «[A-Z0-9+&@#/%=~_|$]»
A character in the range between “A” and “Z” «A-Z»
A character in the range between “0” and “9” «0-9»
One of the characters “+&@#/%=~_|$” «+&@#/%=~_|$»
-->