Pattern pattern = Pattern.compile("(?<word>.+?)(\\t|\\z)");
Matcher matcher = pattern.matcher(msg);
List<String> results = Lists.newArrayList();
while (matcher.find()) {
//System.out.println("match:'" + matcher.group(1) + "'");
results.add(matcher.group(1));
}
assertEquals(Arrays.asList("hello", "world", "foo"), results);
}
@Test