Background Information
I have a csv file with lines that look like this:
+11231231234,13:00:00,17:00:00,1111100,12345,test.net
+11231231234,,,0000000,23456,test.net
+11231231234,18:00:00,19:00:00,1111100,09991,test.net
The lua pattern I have right now is this:
local id, start_time, end_time, asd, int, domain = line:match("(%+%d+),([%d%d:]*),([%d%d:]*),(%d*),([%d%*%#]*),(%a*.*)")
And its working
Question
How would I change this pattern so that IF the start_time / end_time values exist, I want to extract ONLY the first two sets of numbers? So for example, from this input:
+11231231234,18:00:00,19:00:00,1111100,09991,test.net
I would like to end up with these values:
start_time = 18:00
end_time = 19:00
instead of
start_time = 18:00:00
end_time = 19:00:00
What I've Tried
I've tried changing this:
line:match("(%+%d+),([%d%d:]*),([%d%d:]*),(%d*),([%d%*%#]*),(%a*.*)")
to this:
line:match("(%+%d+),([%d%d:%d%d]*),([%d%d:%d%d]*),(%d*),([%d%*%#]*),(%a*.*)")
But it was a no go
EDIT 1
I changed the pattern to this:
line:match("(%+%d+),(%d*:?%d*)[%d:]*,(%d*:?%d*)[%d:]*,(%d*),([%d%*#]*),(%S*)")
And in some cases, its working... but in the following scenarios, it fails:
+11231231234,00:00:00,00:00:00,1111100,12345,test.net
So when the timestamp is zero across the board, it doesn't correctly trim the seconds. I'm currently reviewing the code to make sure it's not a typo on my end. Thanks.