Tuesday, 15 May 2012

regex - regular expression to exclude a specific string -



regex - regular expression to exclude a specific string -

i implementing identity management solution provide users ability manage of endpoint accounts.

currently, our company password policy matches default windows requirements: must contain either number or special character, among others.

unfortunately, in new system's password policy, can require number, special, or both, not "one of either." however, new scheme allows validation regular expression.

currently, have set disallow next regex:

.*[pp][aa4][ss$]{2}[ww][oo0][rr][dd].*

this works pretty well. however, alter allow either digit or special, while disallowing previous. here have tried:

((?=.*\d.*)|(?=.*[-'"!#$%&()*+,./:;<=>?@[\]\^_`{|}~\\].*))(?!.*[pp][aa4][ss$]{2}[ww][oo0][rr][dd].*)

however, can't work. digit/special grouping works fine, word grouping not. see if "password" or variation used @ end of string, not @ beginning...

any suggestions? scheme uses standard (perl-style) regular expressions.

through trickery possible combine regexes.

^([^pp\d!\-'"#$%&()*+,./:;<=>?@[\]\^_`{|}~\\]|[pp](?![aa4][ss$]{2}[ww][oo0][rr][dd]))*(\d|[-'"!#$%&()*+,./:;<=>?@[\]\^_`{|}~\\])([^pp\d!\-'"#$%&()*+,./:;<=>?@[\]\^_`{|}~\\]|[pp](?![aa4][ss$]{2}[ww][oo0][rr][dd]))*$

i've succesfully tested in sublime text editor.

regex regex-negation regex-lookarounds

No comments:

Post a Comment