`
寻梦者
  • 浏览: 625908 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

java中正则表达式过滤字符串

 
阅读更多
public class Test {

	public static void main(String[] args) {
		System.out.println(regexReplace("test","test"));;
		Person person = new User();
		System.out.println(person.getName());
		
     }
	
	public static int regexReplace(String strAim, String strPart){	
		Pattern p = null;
		Matcher m = null;
        int count = 0;
		p = Pattern.compile(strPart);
		m = p.matcher(strAim);
		while (m.find()) {  
			count++;
		}
		return count;
	}
}
 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics