I am using a regular expression in an MVC app that allows users to create a username that includes many special characters, including *
. One small problem, when searching for a user, we allow wildcard searches that use the *
for the wildcard portion of the search. This is what the regular expression looks like on the creation side:
@"^([a-zA-Z0-9!\@#\$%\^&\*\(\)-_\+\.'`~/=\?\{\}\|]){6,255}$"
And here is what the regular expression would look like on the search side:
@"^([a-zA-Z0-9!\@#\$%\^&\*\(\)-_\+\.'`~/=\?\{\}\|]){6,255}$|([\w]){0,0})"
Is there a way to make this work properly by allowing a user to search a whole username that may include a *
in the username, while still allowing other users to use the *
as a wildcard search?