Issue
I'm trying to match 3 groups, where one is conditional
String: 12345-12345-1230
Group 1: 12345-12345
Group 2: -123
Group 3: 0
However I only want to match Group 2 if the string is NOT "-000". Meaning group 2 will either be blank if that section is '-000' or it will be whatever else those 4 characters are; '-123' '-001', etc.).
Here is the REGEX with it just accepting anything as group 2: ^(.{5}-.{5})(.{4})([0-9])$ regex101
What I've tried
Negative Lookahead:
- ^(.{5}-.{5})(?!-000)([0-9])$
- ^(.{5}-.{5})(.{4}(?!.{4}))([0-9])$
OR Operator:
- ^(.{5}-.{5})(-000)|(.{4})([0-9])$
- This is the closest I've come, however I can't get it to work WITH the final condition ([0-9])$. It's also not ideal to have the remove case (-000) as a separate group as the accept case (not -000).