http://www.perlmonks.org?node_id=1173600


in reply to Regular expression to check for qwerty sequence in a password

Hi brad,

You may want to be a bit more specific in your definition of sequences. From what you've said it isn't clear what you mean. for e.g. would the sequence fdsa be acceptable? What about Asdf or asDf?

Either way; if I were to divine what you're trying to accomplish, i.e. to match a string of at least three chars that does NOT contain a multi-char sequence like "asd" or "wer" - I would tweak your if conditional and reg exp to something like this:

if (length($password) > 2 && ($password =~ m/(?:^(?!(asd)|(wer)))/))

Cheers,
Shadowsong