java实现从报文中获取投保单号

投保单号正则表达式:

String regex = "<proposalNo>([0-9]+)</proposalNo>[\\s\\S]*<proposalNo>([0-9]+)</proposalNo>";

String [] arry = matchObject(regex, responseXml);

public static String [] matchObject(final String regex,final String xml){
  List<String> array = new ArrayList<String>();
  Pattern pattern = Pattern.compile(regex);
  Matcher matcher = pattern.matcher(xml);
  if(matcher.find()){
    int countX = matcher.groupCount();
    for(int i=1;i<=countX;i++){
    array.add(matcher.group(i));
    }
  }
  return array.toArray(new String[array.size()]);
}
-----------------------------------------
05-17 05:09