I'm trying to get all occurrences of a bigram out of a string.
So below I have some code which does some of it.
String testString = "Lorem ipsum dolor sit amet.";
Pattern pat = Pattern.compile("\\w+ \\w+");
Matcher mat = pat.matcher(testString);
while (mat.find()) {
System.out.println("Match: " + mat.group());
}
What I got was:
Match: Lorem ipsum
Match: dolor sit
Whereas the result I want is:
Match: Lorem ipsum
Match: ipsum dolor
Match: dolor sit
Match: sit amet