6

I need a regex for 1 uppercase 1 special character and 1 lowercase Note need to allow all special character and it should be above 8 character in length.

I have tried /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/ this but this is restricting some special character.

4
  • Is this for password checking? - which language? Commented Nov 12, 2015 at 11:59
  • 1
    How about this stackoverflow.com/a/32761797/179669 Commented Nov 12, 2015 at 12:01
  • yes password checking javascript Commented Nov 12, 2015 at 12:05
  • @Bakudan I prefer stackoverflow.com/a/9478691/1804181 Commented Nov 12, 2015 at 12:32

2 Answers 2

9

Try to use this regex:

^(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+*!=]).*$ 

REGEX DEMO

Explanation:

(/^ (?=.{8,}) //should be 8 characters or more (?=.*[a-z]) //should contain at least one lower case (?=.*[A-Z]) //should contain at least one upper case (?=.*[@#$%^&+*!=]) //should contain at least 1 special characters .*$/) 
Sign up to request clarification or add additional context in comments.

2 Comments

great explanation and use of the regex demo! +1 thanks! a new site in my repertoire of useful utilities
@Madivad:- You are welcome!
3

I would use:

^(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[^\w\d]).*$ 

Note that [^\w\d] allow any special char.

1 Comment

This would require any special character. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.