match Password by regex - Android java.util.regex

Android examples for java.util.regex:Character Pattern

Description

match Password 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_PASSWORD_REG = "[A-Za-z]+[0-9]";

    public static boolean Password_reg(String value) {
        return match(V_PASSWORD_REG, value);
    }/*from www  .j  av  a 2 s. 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