日期:2014-05-20 浏览次数:20663 次
public class Test25 { public static void main(String[] arg) { String str = "Life likes using google, you need to know what you are searching for, ing."; String[] strs = str.split("(?i)[^a-zA-Z0-9\u4E00-\u9FA5]"); for (String s : strs) { if (s.contains("ing")) System.out.println(s); } } }
------解决方案--------------------
Pattern p = Pattern.compile("(([a-zA-Z]*)?ing)\\b");
String str = "Life likes using google, you need to know what you are searching for, ing.";
Matcher m = p.matcher(str);
while(m.find()){
System.out.println(m.group());
}