I have the below regular expression.
^((?=.{10,32}$)(?=.*[A-Z])(?=.*[a-z]))
The regular expression has the following functionality:
I want to add one more validation. I do not want any continuous repeating character.
Can you please help me?
You can use a Negative Lookahead to do this.
^(?=.{10,32}$)(?=.*[A-Z])(?=.*[a-z])(?!.*(.)\1).+$
This would match any pair of identical characters:
"(.)\1"
Here little program.
static void Main(string[] args)
{
string a = "12223";
string b = "P12345";
bool z = Regex.IsMatch(a,@"(.)\1");
bool x = Regex.IsMatch(b,@"(.)\1");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.