Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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

public class Main {

    public static boolean checkPwd(int type, String name) {

        String regEx = "";

        switch (type) {
        case 0:
            regEx = "^[A-Za-z0-9_]{6,20}$";
            break;
        case 1:
            regEx = "^[\\u4E00-\\u9FA5A-Za-z]+$";
            break;
        case 2:
            regEx = "^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$";
            break;
        case 3:
            regEx = "^[\\u2E80-\\u9FFF]+$";
            break;
        case 4:
            regEx = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$";
            break;
        default:
            break;
        }

        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(name);
        return m.matches();
    }
}