java正则表达式匹配字符中多少个字母,数字,空格
1个回答
推荐于2016-08-03
展开全部
package test;
public class JButtonTest
{
public static void main ( String[] args )
{
String input = "asdf2323 4sdfsdf232 23fsdf";
String reg1 = "[a-zA-Z]", reg2 = "\\d", reg3 = "\\s";
String temp = "|" + input + "|";
int count1 = temp.split (reg1).length - 1;
int count2 = temp.split (reg2).length - 1;
int count3 = temp.split (reg3).length - 1;
System.out.println (count1);
System.out.println (count2);
System.out.println (count3);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询