var url = "https://api.xxx.com/search?name=xxx&age=xxx&sex=xxx";
Given this url, match the parameter string following ?
(not including?) through a regular expression. Please tell me how to write the regular expression. Xiaobai asks for advice~~
漂亮男人2017-06-12 09:31:39
Because js does not support forward lookahead syntax, it cannot use the syntax (?<=?)
, so we can only save the country through curves:
var url = "https://api.xxx.com/search?name=xxx&age=xxx&sex=xxx";
var reg = /\?[^"/]+/
var result = reg.exec(url)
para = result[0].slice(1)
console.log(para)
// 输出:
name=xxx&age=xxx&sex=xxx
我想大声告诉你2017-06-12 09:31:39
This does not require regularization.
pos = str.indexOf('?')
str.substring(pos+1)