AKX is almost right but it's more than that.
19|20\d\d
will match either 19
OR 20 followed by 2 digits
.
But it will not match 19 followed by 2 digits
.
Have a look here: https://regex101.com/r/lvYGUb/3
You'll see 2010 is a single match whereas 19 is matched alone, without the 93
, and as a consequence the 93 goes with the .txt
group, which is probably not what you want
In a similar way, consider this data file :
20 euros
20 €
Let's say you want to match 100% of both lines using a regex.
\d+ euros|€
won't work because it means either a number followed by the word euros
OR just the € sign alone
But
\d+ (euros|€)
will work
So the purpose of the parentheses here is not capturing the group, they are just meant to put a boundary to the OR operator.
If you don't want those parentheses to capture the group, you can add ?:
to make it a non-capturing group, like so:
^(.*?)((0|1)?\d)-((0|1|2|3)?\d)-((?:19|20)\d\d)(.*?)$