regex - Regular expression for accepting alphnumeric characters (6-10 chars) .NET, C# -
I am creating a user registration form using C # with .NET. I have to validate the user entering the password. The validation requirement is as follows.
- It should be alphanumeric (az, AZ, 0-9)
- It should accept 6-10 characters (minimum 6 letters, maximum 10 < Li> With at least 1 alphabet and number (example:
stack1over
) I am using a regular expression below.
< Pre ^ ([a-zA-Z0- 9] {6,10}) $
This satisfies my first 2 terms when it fails I only enter letters or numbers.
If you can If they are, then pass it through many regexes. It will be much cleaner than those looking-ahead monstrosities: -) [/ a> While some people may understand it clever, with a single regex all It is not necessary to do something (or even with any regex, sometimes - only witnesses) that people want to regex to find numbers between 75 and 4093).
Do you want to see some good clean code like:
If not checked then rijks (str, "^ [0- 9] + $") returned incorrectly Value = string_to_in (str); Returns (Val & gt; = 75) and (Val & lt; = 4093)
or something like this:
Return checks (str, ^ 7 [5-9] $ | ^ [89] [0-9] $ | ^ [1-9] [0-9] [0-9] $ | ^ [1-3] [0-9] [ 0-9] [0-9] $ | ^ 40 [0-8] [0-9] $ | ^ 40 9 [0-3] $ ")
I know I like to keep I : -)
Comments
Post a Comment