求教正则表达式的简单运用
怎样判断一个字符窜str是纯数字的和纯字母的?
我是这样写的,请问有什么错误?
纯数字
System.String ex = @"^[0-9]*";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex( ex );
bool flag = reg.IsMatch( str );
纯字母
System.String ex = @"^[a-zA-Z]*";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex( ex );
bool flag = reg.IsMatch( str );