When trying to write an expression in C #, the Regex expression is correct and matches the line:
String telRegex = @"(^0[0-9]{10})|(\(0[0-9]{4}\)[0-9]{6}$)";
Match telRegexResult = Regex.Match(textBox1.Text, telRegex);
if (telRegexResult.Success) {
MessageBox.Show("Your Regex Matches!");
} else MessageBox.Show("Your Regex doesn't match!");
If I put “01446847362”, it will show that the regular expression matches, which is the intended result, but if I also put “01446847362word”, it will also show that it is correct.
Is there anything I can add to my regex to disable it?
source
share