Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/410.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.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正则表达式问题_Javascript_Regex - Fatal编程技术网

Javascript正则表达式问题

Javascript正则表达式问题,javascript,regex,Javascript,Regex,我试图构建一个正则表达式来测试推荐人是否包含某个url(但包括查询参数等) 如果情况不好,我会道歉,但这是我第一次尝试: (ftp|http|https):\/\/urlhere\.com\/directoryhere(\?|/[^-+(a-zA-Z)]|$) 它在这里非常有效: 但是,当我在JavaScript/Firebug中尝试时,使用: document.referrer.match(/(ftp|http|https):\/\/urlhere\.com\/directoryhere(

我试图构建一个正则表达式来测试推荐人是否包含某个url(但包括查询参数等)

如果情况不好,我会道歉,但这是我第一次尝试:

(ftp|http|https):\/\/urlhere\.com\/directoryhere(\?|/[^-+(a-zA-Z)]|$)
它在这里非常有效:

但是,当我在JavaScript/Firebug中尝试时,使用:

document.referrer.match(/(ftp|http|https):\/\/urlhere\.com\/directoryhere(\?|/[^-+(a-zA-Z)]|$)/gi);
我得到一个错误:

SyntaxError:unterminated insertional


感谢您的帮助。

有一个
/
在directoryhere-(\?|/[

(ftp|http|https):\/\/urlhere\.com\/directoryhere(\?|\/[^-+(a-zA-Z)]|$)

[^-+(a-zA-Z)]

之前,您错过了越狱一次

试一试


但是它只返回null?是否应该返回false?在您的案例中,
说明了什么。referer
返回了什么?谢谢,也使用了您的模式和下面的答案。
document.referrer.match(/(ftp|http|https):\/\/urlhere\.com\/directoryhere(\?|\/[^-+(a-zA-Z)]|$)/gi);