I have SOAP data with strings as messageBody present. I want to search second occurrence of "messageBody"(without quotes) pattern. I have tried below code for matching the pattern, but it did not worked :
public static void main(String[] args) {
System.out.println(from3rd("harsh harsh"));
}
private static Pattern p = Pattern.compile("(/[^/]*){2}harsh([^/]*)");
public static String from3rd(String in) {
Matcher m = p.matcher(in);
if (m.matches())
return m.group(2);
else
return null;
}