正则表达式;
1.完全匹配,直接输入字母数字
2.. 占位通配
3.多个中的的任意一个[" "]
import java.util.Scanner; public class RegularExpression { public static void main(String[] args) { System.out.print("请输入:"); Scanner scanner =new Scanner(System.in); String []q={scanner.next()}; regular(q); } public static void regular(String []q){ if(q.length>0){ for (String x:q){ if(x.matches("[0-9]")){ System.out.println("is ok"); }else{ System.out.println("is NG"); } } }else{ System.out.println(" no data"); } } }