final String str = "I want to get previous or next string";
final Matcher matcher = Pattern.compile("or").matcher(str);
if(matcher.find()){
System.out.println(str.substring(matcher.end()).trim());
}
I want to get:"previous" or "next" strings
output: next string