Skip to content

Instantly share code, notes, and snippets.

@digvijaybhakuni
Forked from anonymous/gist:0f09a7b95c286b2469cc
Last active August 29, 2015 14:04
Show Gist options
  • Save digvijaybhakuni/802c0a743ed13e44773d to your computer and use it in GitHub Desktop.
Save digvijaybhakuni/802c0a743ed13e44773d 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