[英]RegEx for pattern in c#
I am still learning RegEx so I need some help on this one. 我仍在学习RegEx,因此在此方面需要一些帮助。
Rules are as below: 规则如下:
Examples: 例子:
12345 – allowed
Os342 – allowed
2O3d3 – allowed
3sdfds dsfsdf – not allowed
Sdfdf.sdfdf –now allowed
What about: 关于什么:
string input = "12345";
bool match = Regex.IsMatch(input, "^[a-z0-9]{1,5}$", RegexOptions.IgnoreCase);
怎么样
^[A-Za-z0-9]{1,5}$
^[a-zA-Z0-9]{1,5}$
[a-zA-Z0-9]
specifies the ranges allowed [a-zA-Z0-9]
指定允许的范围 ^
specifies start of string ^
指定字符串的开头 $
specifies end of string $
指定字符串的结尾 {1,5}
indicates minimum and maximum number of characters for the range {1,5}
表示该范围的最小和最大字符数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.