正则表达式进行字符串替换!将奇数和偶数的字符串替换成不同的!并且忽略大小写查找...

	Pattern p = Pattern.compile("java", Pattern.CASE_INSENSITIVE);
		Matcher m = p.matcher("java Java JaVa IloveJAVA you hate jaVAadsladl");
		StringBuffer buf = new StringBuffer();
		int i = 0;
		while(m.find()) {
			i++;
			if(i %2 == 0){
				m.appendReplacement(buf, "java");
			} else {
				m.appendReplacement(buf, "JAVA");
			}
		}
		p(buf);
		
		



展开阅读全文

没有更多推荐了,返回首页