Hello All,
I am using a RegEX tool to parse times using the following formula: (\d{2}:\d{2}:\d{2}.\d{3}) in this format: 00:00:14.522
The problem I have is when the runtime is under 10 seconds the time appears like this: 00:00:8.304 ith only a single digit for seconds (this doesn't happen for single minute or hour values).
Is there any way to put a range for the number of digits at the highlighted part of the formula?
(\d{2}:\d{2}:\d{2}.\d{3})
Appreciate any help.
Josh
Solved! Go to Solution.
@JoshMcG You can specify a range as {2,#} where # is the upper end of your range, and flip this for a lower end.
Alternatively I believe you could write it as \d+:\d+:\d+.\d+ and it should capture any digits between the symbols.
Not an Regex Expert. There might be a better way to do it. But the below 2 work for me
(\d{2}:\d{2}:\d{1}.\d{3}) | (\d{2}:\d{2}:\d{2}.\d{3})
or
(\d{2}:\d{2}:(\d{1}|\d{2}).\d{3})
@neilgallen
This solution worked: \d+:\d+:\d+.\d+
This one did not: {2,#}
Thanks very much for your time and help, appreciate it,
Josh