正则表达式 - 20 个字符长的数字,只有空格 如何
RegEx - 20 Characters long numbers only with spaces How
我对正则表达式完全没用我需要做的是定义一个模式,该模式将允许最少 5 个字符的字符串最多 20 个字符将只允许空格和数字,没有 A-Z。
有什么想法吗?
您可以使用以下正则表达式:
@"^[\d ]{5,20}$"
解释:
^ # the beginning of the string
[\d ]{5,20} # any character of: digits (0-9), ' ' (between 5 and 20 times)
$ # before an optional \n, and the end of the string
我对正则表达式完全没用我需要做的是定义一个模式,该模式将允许最少 5 个字符的字符串最多 20 个字符将只允许空格和数字,没有 A-Z。
有什么想法吗?
您可以使用以下正则表达式:
@"^[\d ]{5,20}$"
解释:
^ # the beginning of the string
[\d ]{5,20} # any character of: digits (0-9), ' ' (between 5 and 20 times)
$ # before an optional \n, and the end of the string