日期:2014-05-20 浏览次数:20857 次
public static void main(String[] args) throws ParseException { String testStr = "\"aabs.333\",\"aac.11\",\"111ddddd.3122\""; String reg = "\"[^\\.]*\\.([^\"]+)\""; Pattern p = Pattern.compile(reg); Matcher matcher = p.matcher(testStr); while (matcher.find()) { System.out.println(matcher.group(1)); } }
------解决方案--------------------
很赞!
System.out.println("aabs.333".substring("aabs.333".lastIndexOf(".")+1));
------解决方案--------------------
只满足LZ的需求的话很简单:
public static void main(String[] args) { String strings[] = { "aabs.333", "aac.11", "111ddddd.3122" }; for (String str : strings) { if (str.contains(".")) System.out.println(str.substring(str.lastIndexOf('.') + 1)); } }