java正则表达式,验证图片格式

String reg = ".+(.JPEG|.jpeg|.JPG|.jpg|.GIF|.gif|.BMP|.bmp|.PNG|.png)$";
        String imgp= "C:\\Documents and Settings\\Administrator\\桌面\\img.GIF";
        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(imgp.toLowerCase());
        System.out.println(matcher.find());

你可能感兴趣的:(java正则表达式)