i need a certain string to be in this format:
[0000] anyword
so between the [] brackets i need 4 numbers, followed by a whitespace. after that only characters ranging from a to z and – characters are allowed.
so this should be allowed:
[0000] foo-bar
[0000] foo
[0000] foo-bar-foo
etc..
so far i have this:
\[[0-9]{4}\]\s
this matches the [0000] , so it maches the brackets with 4 numbers in it and the whitespace.
i can’t seem to find something that allows charachters after that. i’ve tried putting a single “.” at the end of the expression as this should match any character but this doesnt seem to be working.
\[[0-9]{4}\]\s^[A-Z]+[a-zA-Z]*$
the above isn’t working either..
i need this expression as a Validationexpression for an asp.net custom validator.
any help will be appreciated
This works for your input: http://regexr.com/?30sb7. Unlike Cornstalk’s answer it does not capture anything, and
-can indeed be placed later in a range if it’s escaped.