Regex URL字符串上的正则表达式在';(';或';)';存在

Regex URL字符串上的正则表达式在';(';或';)';存在,regex,vb.net,Regex,Vb.net,我有一些代码可以识别字符串中的URL,并将其转换为超链接: MyString = Regex.Replace(MyString, "(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])", Function(match As Match) String.F

我有一些代码可以识别字符串中的URL,并将其转换为超链接:

MyString = Regex.Replace(MyString, 
                         "(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])", 
                         Function(match As Match) String.Format("<a href=""{0}"">{0}</a>", match.ToString()))
…被替换为

<a href="http://my.intranet/CustomerServices/Internal/Staff">http://my.intranet/CustomerServices/Internal/Staff</a>(Admin)ProcedureChanges.asp
(管理)程序更改.asp

任何人都可以修改正则表达式以允许这些字符包含在URL中吗?谢谢。

我建议将
符号添加到第三组(并将第一组符号压缩为
https?
):

请注意,您不需要在字符类内转义
+


试试
https?://[\w\-\\+(\.[\w\-\\+)+([\w\-,@?^=%&;://()+\\]*[\w\-@?^=%&;//+\\]])
。似乎有效-谢谢。如果你能发布一个答案,我将接受并关闭。那太好了,非常感谢你的解释。
<a href="http://my.intranet/CustomerServices/Internal/Staff">http://my.intranet/CustomerServices/Internal/Staff</a>(Admin)ProcedureChanges.asp
https?://[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&amp;:/~()+#]*[\w\-@?^=%&amp;/~+#])