java正则表达式怎么表示字符串

2024-11-01 23:27:47
推荐回答(1个)
回答(1):

String regEx = "([\s\S]*?)";
String s = "123456789";
Pattern pat = Pattern.compile(regEx);
Matcher mat = pat.matcher(s);
boolean rs = mat.find();
for(int i=1;i<=mat.groupCount();i++){
  System.out.println(mat.group(i));
}