*COMPLETED: 25 Apr 2020 [09:08:21] |TIME: 00:13:49 *
I would like to capture the information as below:
DateEnd : 25 Apr 2020 [09:08:21]
Duration: 00:13:49
I have tried the regular expression below but unable to correctly get the right information.
(?P<DateEnd>(?<=\*COMPLETED\:). )]\s (?P<Duration>(?<=\|TIME\:). )\*
CodePudding user response:
Try this:
COMPLETED: *(?<DateEnd>. ?]).*TIME: *(?<Duration>\S )
See live demo.
You don't need to escape colons :
and you don't need look arounds.
I'm not sure if your flavour of regex needs the P
in the named groups, but none I know need the P
so I removed them and as per the demo it works.