[英]javascript get href.replace the middle string
my url is http://localhost:8080/?usrType=t#52773890547536126
我的网址是
http://localhost:8080/?usrType=t#52773890547536126
i want output as httplocalhost808052773890547536128
我想输出为
httplocalhost808052773890547536128
i have tried this in javascript我在javascript中试过这个
config.channel = config.channel || location.href.replace(/\/|:|#|%|\.|\[|\]/g,'');
it gives httplocalhost8080?usrType=t52773890547536126
它给
httplocalhost8080?usrType=t52773890547536126
You need to replace everything between ?
你需要更换之间的一切
?
and #
in addition to removing all those special characters.和
#
除了删除所有这些特殊字符。
config.channel = config.channel || location.href.replace(/\?.*?#|[\/:#%.\[\]]/g,'');
You can use the character set [\\/:#%.\\[\\]]
instead of all those single-character alternatives.您可以使用字符集
[\\/:#%.\\[\\]]
代替所有这些单字符替代项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.