package org.example; //regex101.com reference import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegExExample { public static void main(String[] args) { String text = "Hello, my name is Philip."; // regex define pattern test String pattern = "\\b\\w+\\b"; // compile the pattern code Pattern regex = Pattern.compile(pattern); // Create a matcher for the text Matcher matcher = regex.matcher(text); // find and print all matches while (matcher.find()) { System.out.println("match found: " + matcher.group()); } // while } // main } // RegExExample