我正在尝试将包含某些URL的String替换为与浏览器兼容的链接URL.
我的初始String看起来像这样:
"hello, i'm some text with an url like http://www.the-url.com/ and I need to have an hypertext link !"
我想得到的是一个字符串看起来像:
"hello, i'm some text with an url like http://www.the-url.com/ and I need to have an hypertext link !"
我可以使用以下代码行捕获URL:
String withUrlString = myString.replaceAll(".*://[^<>[:space:]]+[[:alnum:]/]", "HereWasAnURL");
也许regexp表达式需要一些修正,但它工作正常,需要在更长的时间内进行测试.
所以问题是如何保持regexp捕获的表达式,只需添加创建链接所需的内容:catched string
提前感谢您的关注和回复!