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

Link to comment
Share on other sites

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. Edited by Christian F.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.