Hi,
I'm trying to create a regular expression for a user name.
Here are the rules 1) At least 8 characters and at most 50 characters 2) Allows A-Z, a-z, numbers, and any other character except / character.
Thank you, -Tesh
Hi,
I'm trying to create a regular expression for a user name.
Here are the rules 1) At least 8 characters and at most 50 characters 2) Allows A-Z, a-z, numbers, and any other character except / character.
Thank you, -Tesh
This should work for you...
[^/]{8,50}
If you want to be more specific about which characters you want to include then you can do something like this instead...
[A-Za-z0-9,\.!@#\$%\^&\*\(\)\-_\+\=]{8,50}
Use
\A[^/]{8,50}\Z
or, in C#:
Regex regexObj = new Regex(@"\A[^/]{8,50}\Z");
The start-and-end-of-string anchors \A
and \Z
are necessary because otherwise regexObj.IsMatch()
would return True even if only a part of the regex would match, and you want the string to match in its entirety.