正则表达式用空格字符的最终有界的url - regex to unbound with a space character eventually bounded urls

- 此内容更新于:2015-12-20
主题:

考虑这个字符串,dummyurls可以是任何东西:什么是正则表达式用空格字符的最终有界url得到以下结果:

原文:

considering this string, where dummyurls can be anything:

"http://dummyurl1http://dummyurl2 http://dummyurl3"

What would be the regex to unbound with a space character eventually bounded urls to get the following result:

"http://dummyurl1 http://dummyurl2 http://dummyurl3"
网友:取而代之的是代码:

(原文:([^\s])http replaced by $1 http Code: $re = "/([^\\s])http/"; $str = "http://dummyurl1http://dummyurl2 http://dummyurl3\n"; $subst = "$1 http"; $result = preg_replace($re, $subst, $str);)

楼主:@Tushar非常感谢

(原文:@Tushar Thank you very much)

解决方案:

原文:
str = str.replace(/([^\\s])http/g, ' http');