[英]Why isn't this split in javascript working?
Maybe I drank too much tonight, but why isn't this split on the question mark working? 也许我今晚喝得太多了,但是为什么问号上的这种分歧不起作用?
url = "report/app?start_date=&end_date=&industries"
url.split('/\?/');
You're splitting using the String whose content is /\\?/
. 您正在使用内容为
/\\?/
的String进行拆分。 Use a regex literal instead, to split on using the regex. 请改用正则表达式文字,以使用正则表达式进行分割。
url.split(/\?/);
Howevery, you could simply do url.split('?')
但是,您可以简单地执行
url.split('?')
您需要删除正则表达式定界符/
周围的引号。
url.split(/\?/);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.