My regex is a little rusty and I could use some help. I am writing a regex to use for validating a user id for a java application.
The two rules that the id has to meet:
- Must begin with a -, _, 0-9, a-z or A-Z.
- Not allowed to contain a %, backslash, +, /, #, ::, single quote, or double quote
The part I am having trouble with is the double colon. The id can contain a single colon but cannot contain one back to back.
This is what I have come up with but it does not seem to work.
^[a-zA-Z0-9\-_]([^%\+\\\/\#'\"]|^(?!::))+$
Any advice would be great.
^(?!::)only fails the start of the string if it is followed with::. Everywhere else, it does not match anything.