URL的JavaScript正则表达式

阿什

我必须在URL上运行JavaScript正则表达式,以检测URL后的任何(一个或多个)特殊字符,并在其前放置空格,例如:

url, --> url , or url), --> url ),

例如

https://www.microsoft.com),进入(https://www.microsoft.com),

Chiragjn
var myregexp =/(\b(https?|ftp|file|http):\/\/[\-A-Za-z0-9+&@#\/%?=~_|!:,.;]*[\-A-Za-z0-9+&@#\/%=~_|])/g;
var str="http://www.microsoft.com)"; //url
var res=myregexp.exec(str);          //execute regex query  
str=str.substring(0,myregexp.lastIndex)+' '+str.substring(myregexp.lastIndex);

我使用正则表达式查询网址:https : //stackoverflow.com/a/163684

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章