我有这个正则表达式:
[RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$")]
我想知道'
符号是什么意思?这个正则表达式的含义是什么?
答案 0 :(得分:1)
'
意味着它用作上述代码中两个单词之间的分隔。
或者你可以说分离代码。
和' \用于将文本设置为字符串。
[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 [\r\n\t\f ]