match Picture file by regex - Android java.util.regex

Android examples for java.util.regex:Character Pattern

Description

match Picture file by regex

Demo Code


//package com.java2s;

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

public class Main {

    private static final String V_PICTURE = "(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$";

    public static boolean Picture(String value) {
        return match(V_PICTURE, value);
    }//from w w w . j  ava 2s.c  o  m

    private static boolean match(String regex, String str) {
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(str);
        return matcher.matches();
    }
}

Related Tutorials