Regex for [a-zA-Z0-9\-] with dashes allowed in between but not at the start or end
- by orokusaki
I'm using Python and I'm not trying to extract the value, but rather test to make sure it fits the pattern.
allowed values:
spam123-spam-eggs-eggs1
spam123-eggs123
spam
123
eggs123
I just can't have a dash at the starting or the end. There is a question on here that works in the opposite direction by getting the string value after the fact, but I simply need to test for the value so that I can disallow it. Also, it can be a maximum of 25 chars long, but a minimum of 4 chars long.
Here's what I've come up with after some experimentation with lookbehind, etc:
# Nothing here