Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要JavaScript/Regex来挑选和处理URL_Javascript_Regex - Fatal编程技术网

需要JavaScript/Regex来挑选和处理URL

需要JavaScript/Regex来挑选和处理URL,javascript,regex,Javascript,Regex,我有一个字符串如下所示: “诸如此类,诸如此类……” 例如,类似于上面的字符串,我需要Regex/JavaScript代码返回如下字符串:“rabP4F3Mk&dept=check” 我会尽量说得更准确一些: if (the string contains "example.com/check?x="){ return the portion of the token that contains "example.com/check?x=" after the "=" } /examp

我有一个字符串如下所示:

“诸如此类,诸如此类……”

例如,类似于上面的字符串,我需要Regex/JavaScript代码返回如下字符串:“rabP4F3Mk&dept=check”

我会尽量说得更准确一些:

if (the string contains "example.com/check?x="){ 
   return the portion of the token that contains "example.com/check?x=" after the "="
}
/example\.com\/check\?x=([^\s]+)/
"example.com/check?x=asdfasdf".match(/check\?x=(.*)/)[1]
matches = str.match(/example.com\/check\?x\=([^\s]*)/);
if(matches.length > 1) return matches[1];