// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.regex.Pattern;

public class RegexMatch {
    public static void test(String needle, String haystack) {
        Pattern p = Pattern.compile(needle);
        System.out.printf("Standard match %s in %s : %b\n", needle, haystack, p.matcher(haystack).find());
        Pattern pi = Pattern.compile(needle, Pattern.CASE_INSENSITIVE);
        System.out.printf("Case insensitive match %s in %s : %b\n", needle, haystack, pi.matcher(haystack).find());
    }
    public static void main(String[] args) {
        test("alarm", "AlarmService");
        test("alarmS", "AlarmService");
        test("AlarmS", "AlarmService");
    }
}
