Jump to content

Please help me with this regular expression


mostafatalebi

Recommended Posts

Hello

 

I have two requests buddies:

 

1- I have a regular expression that I have downloaded from the net(source). This would check for the most strong password. Here is the regexp:

 

/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$/;

 

But I need to add a number to above regexp so that only passwords with more than 14 characters be considered as best. So i think i need something like {14,}, but I don't know where to put it.

 

 

2- Please check if this regexp is really complete for using as best password. Thanks

Two quick answers, plus a bonus one:

  • The star in regular expressions means "zero, or more", and the period means "any character, except newlines". Ignore the part in parentheses, as they're zero-width lookaheads, and what you need to change should become clear.
  • Also, on a related note to the other thread, you should be removing that negative lookahead for whitespace in there.
  • This RegExp requires alphanumerical characters, both upper and lower, but no special characters. I, personally, prefer to put a requirement on those too. Just to ensure that the entropy pool is as big as it can get. Makes it that much harder for people to come up with truly terrible passwords, even if it's not fool proof.
For an example of what I use, I just posted a PHP function for password validation. The RegExp should be directly portable to JS.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.