简体   繁体   English

使用正则表达式检查C#中的空格和最小条目

[英]Regular Expression to check the spaces and minimum entries in C#

I am using c# for programming! 我正在使用C#进行编程!

I want to write one regular expression in c# which will check first and last space in a sentence and will allow spaces in between it as well as there should be minimumm 2 charater entry in field, no limit for maximum characters, no special keys are allowed (@,#,$ etc) characters allowed 我想在C#中编写一个正则表达式,该正则表达式将检查句子中的第一和最后一个空格,并在其之间留有空格,并且字段中应至少有2个字符输入,最大字符数没有限制,不允许使用特殊键允许使用(@,#,$等)个字符

Please suggests! 请提出建议!

It's not really clear exactly what you want. 不清楚您到底想要什么。 Your comment -- contradicting the question itself -- suggests something like this, perhaps... 您的评论-与问题本身矛盾-暗示了类似的内容,也许...

^[A-Za-z0-9]+(?:\s*[A-Za-z0-9]+)+$

This means that the string must start and end with an alphanumeric, and all characters except the first and last must be either alphanumeric or whitespace. 这意味着字符串必须以字母数字开头和结尾,并且第一个和最后一个以外的所有字符必须为字母数字或空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM