Here you can find the source of isValidUserNameOrPassword(String string)
public static boolean isValidUserNameOrPassword(String string)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isValidUserNameOrPassword(String string) { Pattern pattern = Pattern.compile("^([a-zA-Z0-9_]+)$"); Matcher matcher = pattern.matcher(string); if (matcher.find()) { return true; } else {//w w w .j a v a2 s. com return false; } } }