• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1696
  • Last Modified:

Regular Expression - partial match of string

I have the following pattern I am using to not allow the username to be used in the password.  This isn't working.

pattern = @"^.*(?=.*[A-Z])(?=.*[a-z])(?<"+txtUserName.Text+@">.*)(?=.*[@#$%^&+=]|.*\d)^.{8,32}.*$";

Please provide assistant in getting this pattern corrected to disallow the username to be used.
Ie.  Username = testuser
     Password could not be   123 testuser123

Thanks
0
shugt23
Asked:
shugt23
1 Solution
 
jax79sgCommented:
pattern = "^.*" +  txtUserName.Text + ".*$" ;

. means any characters
* means 0 or more times
0
 
ozoCommented:
^(?!.*testuser)
0
 
shugt23Author Commented:
Perfect.  Works great.  
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now