How to make sure that I do not allow more than one parenthesis "(" and ")" in the input text? I have the following expression that will allow numbers, spaces, hyphens and brackets to be used.
Regex.Match(text, @"^[0-9 (,),-]+$").Success
I canβt allow something like "((123) 456-7891 or (91) 123-23123 (1)). The correct line could be:" (123) 1231231 or (121) 123-213123.
Edited: Sorry for not understanding. The requirement is to allow only numbers, spaces, hyphens and brackets (only one set). To be specific, "(" must always have a closing bracket ")". As one of you said, not one guy or one set of guys. If someone can also say how to allow a guy in any position, not only in the beginning?
source share