日期:2014-05-20 浏览次数:20807 次
public static List<Integer> getStr(){ List<Integer> strList=new ArrayList<Integer>(); String content = "COUNT(<a billid=\"9160150\">A</a>,<a billid=\"9160151\">B</a>,<a billid=\"9160152\">C</a>)" ; Pattern p=Pattern.compile("\\d{7}"); Matcher m=p.matcher(content); while(m.find()){ String tmp=m.group(); System.out.println(""+tmp); Integer i=Integer.parseInt(tmp); strList.add(i); } return strList; }
------解决方案--------------------
for example
List<String> list = new ArrayList<String>(); String str = "COUNT(<a billid=\"9160150\">A</a>,<a billid=\"9160151\">B</a>,<a billid=\"9160152\">C</a>)" ; Matcher m=Pattern.compile("(?i)billid=\"(\\d+)\"").matcher(str); while(m.find()){ System.out.println(m.group(1)); list.add(m.group(1)); } String[] arr = list.toArray(new String[0]);