I'm trying to create a regex that will allow a specific string only (Test1) for example or numeric values. How would I do this? I have tried the following but it doesn't work and won't notice the string part. What am I doing wrong with this regex?
^Test1[0-9]*$
I want to use it in an MVC model validation attribute:
[RegularExpression("^Test1[0-9]*$", ErrorMessage = "The value must be numeric or be Test1.")]
^(Test1|[0-9]*)$? To matchTest1or zero or more digits?^(?:Test1|[0-9]+)$^Test1|\d+$will match "Test1" or any numeric value.