我有一个属性,比如 IdentityCode
string IdentityCode {get;set;}
我的IdentityCode有三种模式
它有 6 位数字
######---->332145
或者可以用斜杠得到 6 位数字
######/#----->332145/1
######/##----->332145/15
我如何为此设置模式
最佳答案
斜杠在 .Net 正则表达式中并不特殊,因此您可以只写 /
。
更全面:
@"\d{6}(/\d{1,2})?"
关于c# - 带斜杠的正则表达式模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9851583/