简体   繁体   English

需要帮助修改正则表达式

[英]Need help modifing regex

I am currently using the regex given below to add hrefs to my urls. 我目前正在使用下面给出的正则表达式将href添加到我的网址中。 But recently I got a bug because one of the urls had a full stop after it and the regex added the dot into the link. 但是最近我遇到了一个错误,因为其中一个网址在它之后停了下来,并且正则表达式将点添加到了链接中。

(?:https?|ftps?)://[\\w/%.-]+", "<a href='$0'target='_blank'> $0</a> 

So,can it be modfied so that it takes only one dot? 那么,可以修改它使其仅占用一个点吗? I'm using Java. 我正在使用Java。

I used this one: 我用了这个:

(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?

But you can find a lot more here . 但是您可以在这里找到更多。

我像这样编辑了我的,它就起作用了。“(?:https?| ftps?):// [\\ w。] + / [\\ w] +”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM