Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save digvijaybhakuni/35ec9ced226fc5e265c7 to your computer and use it in GitHub Desktop.
Save digvijaybhakuni/35ec9ced226fc5e265c7 to your computer and use it in GitHub Desktop.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Give true is all condition matches, otherwise false.
* @param String
* @return boolean
*/
private boolean validateUserName(String username){
Pattern pattern = Pattern.compile("^[a-z0-9_-]{3,15}$");
Matcher matcher = pattern.matcher(username);
return matcher.matches();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment