java.util.regex.Pattern p = Pattern.compile("/\"(.*?)(?:<[^>]+>)<([^>]*)><([^>]*)>\"/g"); String value = "log L 02/15/2008 - 18:50:28: \"NaNg<23><1133><1133>\" disconnected"; Matcher m = p.matcher(value); System.out.println(m.groupCount()); for (int i = 0; i <= 4; i++) { try { System.out.println(m.group(i)); } catch (Exception exp) { System.out.println(exp.toString()); } } output: 3 java.lang.IllegalStateException: No match found java.lang.IllegalStateException: No match found java.lang.IllegalStateException: No match found java.lang.IllegalStateException: No match found java.lang.IllegalStateException: No match found