Tuesday, 20 August 2013

C# Regex - How to validate for either specific words or numbers but not both

C# Regex - How to validate for either specific words or numbers but not both

I need to validate a value and the requirement is it may either contain
digits 0-9 or a specific words but not both.
I am using the following expression
Regex regex = new Regex(@"\b(Private Bag)\b|[0-9]");
However, if find that using the above expression for validating is passing
for all scenarios.
Where am I going wrong with this regex?

No comments:

Post a Comment