Valid Username Regular Expression

  • + 0 comments

    String regex = "^[[a-z][A-Z]]\w{7,29}$";

    This worked for me. The starting of the Username cannot be _ and if [aA-zZ] is used, everything in between is considered a valid first character including _

    Instead if [a-z][A-Z] is used, it considers only alphabetic characters as the first character in the username.