简体   繁体   中英

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 /\\?/ . Use a regex literal instead, to split on using the regex.

url.split(/\?/);

Howevery, you could simply do url.split('?')

您需要删除正则表达式定界符/周围的引号。

url.split(/\?/);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM