Android examples for java.util.regex:Character Pattern
match Rar zip file by regex
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final String V_RAR = "(.*)\\.(rar|zip|7zip|tgz)$"; public static boolean Rar(String value) { return match(V_RAR, value); }/*from w w w . j a v a2s .co m*/ private static boolean match(String regex, String str) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); } }