我有一个看起来像这样的字符串:
" blah blah blah yada yada http://www.example.com/check?x=rabP4F3Mk&dept=check等等等等......"
例如类似于上面的字符串,我需要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 "="
}
答案 0 :(得分:1)
"example.com/check?x=asdfasdf".match(/check\?x=(.*)/)[1]
答案 1 :(得分:1)
matches = str.match(/example.com\/check\?x\=([^\s]*)/);
if(matches.length > 1) return matches[1];
答案 2 :(得分:0)
/example\.com\/check\?x=([^\s]+)/