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;
	}
}
 

相关推荐