【发布时间】:2015-04-06 15:41:58
【问题描述】:
我有一些这样的数据
Wed Mar 18 15:16:10 2015 eth0:1 109.224.232.219 up (not currently mapped)
Wed Mar 18 15:18:12 2015 eth0:1 109.224.232.219 down (not responding)
Wed Mar 18 15:20:46 2015 eth0:1 109.224.232.219 up (not currently mapped)
Wed Mar 18 15:22:52 2015 eth0:1 109.224.232.219 down (not responding)
Wed Mar 18 15:24:26 2015 eth0:1 109.224.232.219 up (not currently mapped)
我正在尝试捕获每一行的 IP 和日期字符串,我想我可以在 eth 一词之前执行任何操作,然后进行我的 IP 检查,但这不起作用。我是否误解了捕获组的概念?
有没有一种明智的方法可以从 1 个正则表达式中获取这些数据?
(^(.*?)eth)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
任何帮助将不胜感激。
这是当前正则表达式的图像
【问题讨论】:
标签: regex perl expression capture