Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Regular expression to check for qwerty sequence in a password

by shadowsong (Monk)
on Oct 09, 2016 at 17:02 UTC ( #1173600=note: print w/replies, xml ) Need Help??


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

Replies are listed 'Best First'.
Re^2: Regular expression to check for qwerty sequence in a password
by bradcathey (Prior) on Oct 09, 2016 at 17:44 UTC

    Shadowsong

    Sorry for the confusion. I'm trying to test passwords made by just rolling all four fingers on the keyboard, hitting immediately adjacent letters, e.g., "asdf." They must be next to each other: so "asdg" wouldn't match. Case is not necessarily a consideration. Does that help?

    I have been a little surprised in reading the replies to see there is no one magical regex.


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      I have been a little surprised in reading the replies to see there is no one magical regex.

      tybalt89's single regex given here not sufficiently magical?!? You're a hard monk to please!

      ... passwords made by ... hitting immediately adjacent letters, e.g., "asdf." They must be next to each other: so "asdg" wouldn't match.

      tybalt89's regex can easily be modified so that  'asd' 'wert' 'vbnm' etc. are rejected and  'asdx' 'xasd' 'xasdx' etc. accepted. This is left as a penitential exercise for a very demanding monk.


      Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1173600]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2019-05-22 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (138 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!