Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isPwd(String str) { Pattern pattern = Pattern.compile("[A-Za-z0-9_]+"); Matcher isPwd = pattern.matcher(str); if (!isPwd.matches()) { return false; } return true; } }