如何使用正则表达式提取第n个单词?

时间:2014-05-16 02:23:24

标签: regex regex-lookarounds regex-greedy

我的输入看起来像这样

  

2014-05-16 00:45:48 47 192.168.102.177 - - - PROXIED" none" - 0 TUNNELED unknown - ssl pixel.quantserve.com 443 / - - - 192.168.101.70 754 904 - - -

     

2014-05-16 00:45:48 2 192.168.102.177 - - - PROXIED" none" - 200 TCP_ACCELERATED CONNECT - tcp ssl.google-analytics.com 443 / - - " Mozilla / 5.0(Windows NT 6.1; WOW64; rv:29.0)Gecko / 20100101 Firefox / 29.0&# 34; 192.168.101.70 39 221 - "不可用" "不可用"

     

2014-05-16 00:45:26 102314 192.168.102.177 - - - PROXIED" none" - 0 TUNNELED unknown - ssl fbcdn-dragon-a.akamaihd.net 443 / - - - 192.168.101.70 714 1130 - - -

     

2014-05-16 00:45:46 12 192.168.102.177 - - - PROXIED" none" - 200 TCP_NC_MISS POST应用程序/ ocsp-response http ocsp.digicert.com 80 / - - " Mozilla / 5.0(Windows NT 6.1; WOW64; rv:29.0)Gecko / 20100101 Firefox / 29.0 " 192.168.101.70 812 492 - "不可用" "不可用"

我想匹配以粗体突出显示的内容。以下是:

pixel.quantserve.com
ssl.google-analytics.com
fbcdn-dragon-a.akamaihd.net
ocsp.digicert.com

我应该怎么做呢?

1 个答案:

答案 0 :(得分:6)

/(?:\S+\s+){15}(\S+)/

前15个单词匹配但not captured,然后捕获第16个单词。