I need a regex to use in .net that will match a user name as firstname or firstname.lastname with a maxlength of 50 characters. The firstname case is easy but with firstname.lastname I can’t figure out how to only allow 50 minus len(firstname.) in the lastname.
^([a-zA-Z]{1,50})|([a-zA-Z]+[.][a-zA-Z]+)$
will match the firstname case but the second case of firstname.lastname will allow infinite characters in the firstname and lastname.
Will only match if number of
[a-z]s is between 1 and 50.If the total length can never be more than 50, you can use this instead: