I\'m trying to take a string:
String s = \"This is a String!\";
And return all 2-word pairs within that string. Namely:
{\"this
I tried with group of pattern.
String s = "this is a String";
Pattern pat = Pattern.compile("([^ ]+)( )([^ ]+)");
Matcher mat = pat.matcher(s);
boolean check = mat.find();
while(check){
System.out.println(mat.group());
check = matPOS.find(mat.start(3));
}
from the pattern ([^ ]+)( )([^ ]+)
...........................|_______________|
..................................group(0)
..........................|([^ ]+)| <--group(1)
......................................|( )| <--group(2)
............................................|([^ ]+)| <--group(3)