String s = new String("2_8_7.4_3_9_1"); // 字符串
Pattern p=Pattern.compile("[_.]"); //正则 (匹配 _ 和 . 的字符)
Matcher m=p.matcher(s);
while(m.find()){
System.out.println(m.group()); //打印
}
本文详细介绍了如何使用正则表达式匹配并打印字符串中特定的字符(_ 和 .)。通过实例演示了如何创建模式、进行匹配以及提取匹配到的字符。
1万+

被折叠的 条评论
为什么被折叠?