I'm trying to convert a log file from:
我正在尝试转换日志文件:
2/20/2016 12:23:35 PM 80.0
2/20/2016 12:23:36 PM 76.7
2/20/2016 12:23:37 PM 75.0
2/20/2016 12:23:38 PM 75.4
To output only:
仅输出:
80.0
76.7
75.0
75.4
I have a pre-existing regex but it looks for the number with an A after and won't work for these logs. I know there is an EOL find by number but I can't seem to get it to work:
我有一个预先存在的正则表达式,但它会查找带有A after的数字,但不适用于这些日志。我知道有一个EOL按编号查找,但我似乎无法让它工作:
$regex = '/\d+$/'
Thanks!
2 个解决方案
#2
1
Try this:
(?:AM|PM) ([0-9.]+)
Input:
2/20/2016 12:23:35 AM 80.0
2/20/2016 12:23:36 PM 76.7
2/20/2016 12:23:37 PM 75.0
2/20/2016 12:23:38 PM 75.4
Output:
MATCH 1
1. [22-26] `80.0`
MATCH 2
1. [49-53] `76.7`
MATCH 3
1. [76-80] `75.0`
MATCH 4
1. [103-107] `75.4`
#1
#2
1
Try this:
(?:AM|PM) ([0-9.]+)
Input:
2/20/2016 12:23:35 AM 80.0
2/20/2016 12:23:36 PM 76.7
2/20/2016 12:23:37 PM 75.0
2/20/2016 12:23:38 PM 75.4
Output:
MATCH 1
1. [22-26] `80.0`
MATCH 2
1. [49-53] `76.7`
MATCH 3
1. [76-80] `75.0`
MATCH 4
1. [103-107] `75.4`