I am try to split/match a string on Punctuation and white space and also need to get there offset values.
Ex - "I live, in India."
i want output like - ["I","live", ",", "in", "India", "."] and also the start and end index value of each token.
I have tried using -
String text = "I live, in India.";
Pattern p1 = Pattern.compile("\\S+");
Pattern p2 = Pattern.compile("\\p{Punct}");
Matcher m1 = p1.matcher(text);
Matcher m2 = p2.matcher(text);
This will give the desire result but can i combine both the pattern in a single pattern ?