All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ssssssss.magicapi.utils.PatternUtils Maven / Gradle / Ivy

package org.ssssssss.magicapi.utils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;

public class PatternUtils {

	private static final Map cachedPatterns = new ConcurrentHashMap<>();

	public static boolean match(String content, String regex) {
		Pattern pattern = cachedPatterns.get(regex);
		if (pattern == null) {
			pattern = Pattern.compile(regex);
			cachedPatterns.put(regex, pattern);
		}
		return pattern.matcher(content).find();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy