Skip to content

Instantly share code, notes, and snippets.

@mmahadevan-okta
Created March 27, 2014 18:08
Show Gist options
  • Save mmahadevan-okta/9814282 to your computer and use it in GitHub Desktop.
Save mmahadevan-okta/9814282 to your computer and use it in GitHub Desktop.
sanitizeUsername
private String sanitizeUsername(String name) {
LOGGER.debug("sanitizeUsername(" + name + ")");
if ( ! StringUtils.containsOnly(name.toUpperCase(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#$_@")) {
name = name.replaceAll("[^A-Za-z0-9\\#\\$\\_\\@]", "");
}
LOGGER.debug("sanitized to [" + name + "]");
return name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment