Java正则匹配

Java正则匹配

Posted by wenfengSAT on June 26, 2018

Java正则匹配


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test {

	private static Pattern pattern = Pattern.compile("(.*?(?:\\.png|\\.jpg|\\.jpeg|\\.gif|\\.bmp))");
	public static void main(String[] args) {
		Matcher m = pattern.matcher(".png");
		System.out.println(m.matches());
	}
}