14
luaq
6y

String username = "Xx_thelegend27_xX";

final Pattern pattern = Pattern.compile("(xx|(_|))(?<username>\\w*)(_|(xx))", Pattern.CASE_INSENSITIVE);
final Matcher matcher = pattern.matcher(username);

if(matcher.matches()){
this.showError(String.format("Your username cannot be that... Try: %s", matcher.group("username")));
}else {
registerOrSomething();
}

Comments
  • 4
    I haven’t seen Xx_Username_xX in a long time!
  • 0
    Your username cannot be that... try StopMotionCuber

    *types StopMotionCuber*

    Sorry, that username is already taken
Add Comment