C#中仅字母字符的正则表达式 [英] regular expression for only alpha characters in C#
本文介绍了C#中仅字母字符的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想了解C#代码中仅字母字符的正则表达式
i want to know the regular expression for only alpha characters in C# code
推荐答案
您本可以尝试
You could have tried a Google search[^] first.
<asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="txtYourControlId"
ValidationGroup="ValidGroup" Display="Dynamic" ValidationExpression="^[a-zA-Z'.\s]"
Text="Please enter alphabets only" />
使用此方法:ValidationExpression ="^ [a-zA-Z''.\ s]"
Use this : ValidationExpression="^[a-zA-Z''.\s]"
您可以使用正则表达式执行相同的操作:
you can use regular expression to do the same:
//use System.Text.RegularExpressions
if (Regex.IsMatch("^[a-zA-Z]", textBox1.Text))
{
//assign error to label
}
这篇关于C#中仅字母字符的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文