I'm trying to create a Java regex that will not match a string that:
- starts with
rc-
- starts with
env-
- is exactly
master
So the results should be:
Not a match: `master`
Not a match: `rc-blah`
Not a match: `env-demo`
Not a match: `rc-1.2.34`
Is a match: `something`
Is a match: `issuance-fix`
Is a match: `something-env-blah`
Is a match: `master-something`
Is a match: `yes-rc-12.43.56`
Currently I've got ^(?!master|rc-|env-).*$
which is essentially a "doesn't start with" expression. This mostly works but master-something
is flagged as a non-match.
I've tried this: ^((?!rc-|env-).*|(?!master))$
which incorrectly flags master
as a match.
I've tried various other combinations but I can't seem to get the results I want.
Any help appreciated!