需要JavaScript/Regex来挑选和处理URL
我有一个字符串如下所示: “诸如此类,诸如此类……” 例如,类似于上面的字符串,我需要Regex/JavaScript代码返回如下字符串:“rabP4F3Mk&dept=check” 我会尽量说得更准确一些:需要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
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];