import java.util.regex.*;

public class RegexGroupingExample {
    public static void main(String[] args) {
        String regex = "(abc|def)";  // جستجوی "abc" یا "def"
        String input = "abcdef";
        
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(input);
        
        while (matcher.find()) {
            System.out.println("Found: " + matcher.group());  // پیدا کردن abc یا def
        }
    }
}