正则表达式+ c# [英] Regular expression +c#

查看:106
本文介绍了正则表达式+ c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要C#中的正则表达式

我的条件是6到30的最大值,并且可以接受特殊字符,数字和字母.

请在这件事上给予我帮助?谢谢

I need regex in C#

My condition is minimum of 6 max of 30, and accepts special characters, numbers, and letters.

Please help me with this? Thanks

推荐答案

.{6,30}


点(.)匹配换行符(\ n)以外的任何字符,除非您在Regex构造函数中指定RegexOptions.Singleline,在这种情况下,它匹配每个单个字符.并且它始终与回车符(\ r)匹配,以防万一您想知道.而6,30是要使用范围左侧的匹配表达式进行匹配的字符范围(在上述情况下,该字符为点).因此,上面的表达式匹配6到30个字符(任何类型,除了\ n取决于您构造Regex的方式)(包括所有字符).


Dot (.) matches any character except line breaks (\n), unless you specify RegexOptions.Singleline in the Regex constructor, in which case it matches every single character. And it always matches carriage return (\r), just in case you were wondering. And 6,30 is the range of characters to match using the match expression to the left of the range (in the above case, that would be dot). So, the above expression matches between 6 and 30 characters (of any type, except for \n depending on how you construct the Regex), inclusive.


我不会给出您将获得完整的解决方案,但我会给您一个接近的解决方案,您可以完成它:
I''m not going to give you the full solution, but I''ll give you a close one, and you can finish it:
.{9,20}


我建议您阅读正则表达式,这样就不必问这样的基本问题.


I recommend you read up on regular expressions so you don''t need to ask such basic questions.


这篇关于正则表达式+ c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆