public static void main(String[] args){
int num = 0;
String str = "sunjavaIBMjavaOracleJavaHellojavaGoodJava";
Pattern pt = Pattern.compile("java", Pattern.CASE_INSENSITIVE);
Matcher mc = pt.matcher(str);
mc.reset();
while (mc.find()) {
num++;
String gc = mc.group();
System.out.println(" "+num+" :" + gc);
}
System.out.println("java :" + num);
mc.reset();
// java 。 java
while (mc.find()) {
num++;
if (num % 2 == 1) {
String gc = mc.group();
String o1 = gc.toUpperCase();
System.out.println(" :"+o1);
} else {
String gc = mc.group();
String o2 = gc.toLowerCase();
System.out.println(" :"+o2);
}
}
}