Reputation: 1918
I have the following code, which should be passing the regex but it isn't, I'm missing something?
if (Regex.IsMatch("ABC1234", "/^[A-Z]{3}[0-9]{4}$"))
{
//Pasosed Regex
Console.WriteLine("Pass");
}
else
{
Console.WriteLine("No Pass");
}
Output: "No Pass"
Can Anyone help?
Upvotes: 0
Views: 32
Reputation: 1618
Remove the /
from your pattern and it should work.
Console.WriteLine(
Regex.IsMatch("ABC1234", "^[A-Z]{3}[0-9]{4}$").ToString()
);
// True
Upvotes: 1