0
Guys, how do I create a regular expression, where she should accept numbers with DDD, and also accept numbers without DDD?
0
Guys, how do I create a regular expression, where she should accept numbers with DDD, and also accept numbers without DDD?
3
Regex reg = new Regex(@"(\([0-9]{2}\)|)[0-9]{4,5}-[0-9]{4}");
reg.isMatch("(12)12345-1234"); //retorna true
reg.isMatch("(12)1234-1234"); //retorna true
reg.isMatch("12345-1234"); //retorna true
reg.isMatch("1234-1234"); //retorna true
reg.isMatch("123-1234"); //e qualquer outra combinação retorna false
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
Thank you very much Leandro... My mistake was that I was not parenting this part : @"((([0-9]{2})|). I thank you for your help.
– Felipe Moreira
@Felipemoreira, if the answer solved your problem, you can mark as Answer.
– Uilque Messias