1 package org.christianschenk.titletest.util;
2
3 import java.util.regex.Matcher;
4 import java.util.regex.Pattern;
5
6 public class RegExUtils {
7
8 /**
9 * Performs a case insensitive search with the given regular expression in a haystack.
10 *
11 * @return the match or null if nothing was found
12 */
13 public static String findMatch(final String regex, final String text) {
14 final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
15 final Matcher matcher = pattern.matcher(text);
16 while (matcher.find()) {
17 return matcher.group();
18 }
19 return null;
20 }
21 }