C# Regex for atleast one letter and atleast one number -


i'm attempting check verify password had @ least 1 letter , number. follwing doesn;t seem work.

password "tester1" or "11111111t" etc.

can not letters or digits.

any ideas?

const string pattern = @"/[a-z].*\d|\d.*[a-z]/"; var match = regex.match(password, pattern); 

solved:

var rule1 = password.any(char.isletter); var rule2 = password.any(char.isnumber); 

this worked well:

const string pattern = @"[a-z].*\d|\d.*[a-z]"; 

instead of using regex, use simple rules easier maintain. example:

var rule1 = str.all(char.isletter); var rule2 = str.all(char.isnumber); 

and can enrich rules char.islower, char.isupper etc.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -