"正则表达式"属性中的"符号"是什么意思?



我有一个正则表达式:

[RegularExpression(@"^[a-zA-Z''-'s]{1,40}$")]

我想知道'符号是什么意思?它在正则表达式中的含义是什么?

'

意思是它用作两个单词之间的分隔符,就像您在上面的代码中使用的一样。

或者你可以说代码的分离。

和'\use用于将文本设置为字符串。

[RegularExpression(@"^[a-zA-Z''-'s]{1,40}$")]

以上代码含义:

[a-zA-Z''-'s]{1,40} match a single character present in the list below
Quantifier: {1,40} Between 1 and 40 times, as many times as possible, giving back as needed [greedy]
a-z a single character in the range between a and z (case sensitive)
A-Z a single character in the range between A and Z (case sensitive)
' the literal character '
'-' a single character in the range between ' and '
s match any white space character [rntf ]

最新更新