I want to find out if user has used the words admin
or username
anywhere in their possible username string.
So if user wants to use admin
Square brackets in a regexp are not for grouping, they're for specifying character classes; grouping is done with parentheses. You don't want to anchor the regexp with ^
and $
, because that will only match at the beginning and end of the string; you want to use \b
to match word boundaries.
/\b(admin|username)\b/i