Regex to find a username case insensitive

I am trying to create a method to check for unique usernames. For example, if the username JOHN exists, someone else shouldn’t pick the username John. My only problem is that I can’t find the good regex for it. I tried the following:

ParseQuery query = ParseUser.getQuery();
String regex = nickname.getText().toString().toLowerCase();
query.whereMatches("username", regex, "i");

But this also gives the users who have the username Johnny. How can I only find the username John case insensitive?


Source: regex

Leave a Reply