Java tutorial
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { // main method Pattern pattern = Pattern.compile("(?<=sentence).*"); Matcher matcher = pattern.matcher("this is a test!"); boolean found = false; while (matcher.find()) { // if it is found System.out.println("I found the text: " + matcher.group().toString()); found = true; } if (!found) { // if not System.out.println("I didn't find the text."); // say it wasn't found } } }