[英]Issue with regex (3 capital letters proceeding with 4 numbers)
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? 有人可以帮忙吗?
Remove the /
from your pattern and it should work. 从您的模式中删除/
,它应该可以工作。
Console.WriteLine(
Regex.IsMatch("ABC1234", "^[A-Z]{3}[0-9]{4}$").ToString()
);
// True
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.