I'm currently working on a piece of regex that mostly works, however there's a few matches that aren't capturing, despite working when they're the only match. I'm hoping someone can point out what is clearly an obvious error, but one that I'm missing.
Specifically, the string kMad
matches to [Kk\D]
by itself, but not when it's part of the bigger string.
For reference:
Full Regex showing missing matches
Specific Regex showing matches
CodePudding user response:
Non-matching occurrence of kMad10:31-18:5771
does not include 4 digits at the end since two digits after the colon is already captured by (\d{2}:\d{2}\-\d{2}:\d{2})
. You can define a range for the digit occurrences for the regex section after it like \d{2,4}
instead of \d{4}
The new regex will be:
(?:\d{4}\-\d{2}\-\d{2} \.)?(?:Line\d{1,3})?(OFF|ADO|([Kk\D] )?(\d{2}:\d{2}\-\d{2}:\d{2})(\d{2,4}))