Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.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/4/webpack/2.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
Regex 正则表达式名称捕获组don';不包含一个特定的单词_Regex - Fatal编程技术网

Regex 正则表达式名称捕获组don';不包含一个特定的单词

Regex 正则表达式名称捕获组don';不包含一个特定的单词,regex,Regex,我有一个文本模式,它是Apache日志: 18.123.117.10287.153.14.123[08/Jan/2020:10:16:22+0000]“GET/sport/home HTTP/1.1”200 12345 122https://www.google.com“Mozilla/5.0(Windows NT 6.3;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/67.0.3396.99 Safari/537.36”eb72d10e0-

我有一个文本模式,它是Apache日志:

18.123.117.10287.153.14.123[08/Jan/2020:10:16:22+0000]“GET/sport/home HTTP/1.1”200 12345 122https://www.google.com“Mozilla/5.0(Windows NT 6.3;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/67.0.3396.99 Safari/537.36”eb72d10e0-3f9f-42kf-3di6-ff40hegg49f85 157845852510 15787878582612

我建立了一个正则表达式来从这个日志中提取referer,在我们的例子中是
https://www.google.com

^(?:[^\“\n]*\”{3}(?[^\“?]+)


但我需要确保组引用仅在不包含单词时匹配,例如,我想获取所有非google的引用。如何编辑此正则表达式以获得此结果?

您可以在正则表达式中使用负前瞻:

^(?:[^"\n]*"){3}(?<referer>(?![^"?]*\bgoogle\.)[^"?]+)
^(?:[^”\n]*”{3}(?(![^”]*\bgoogle\)[^”]+)

(?![^”?]*\bgoogle\)
是一种消极的前瞻,如果
google.
之前出现,则会导致匹配失败