I have used below function to print next word.
But it prints only first matching word,How to print all words?
string example = " 123 :G Hi all P: word I am new in java :G help me :N abc 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 :R 56 0 0 :G Please; string matchWord= ":G";
public String nextWord(String str, String matchWord) {
Pattern p = Pattern.compile(matchWord + "\\W+(\\w+)");
Matcher m = p.matcher(str);
return m.find() ? m.group(1) : null;
}
Current output: Hi Expected Output: Hi help Please