0

What is the regex to make sure that a given string contains at least one lowercase character and one uppercase character but also my include number s and special characters !@#$%^&*()+=? ?

Does the order of the regex matter?

3

1 Answer 1

1

You can use positive lookahead patterns to ensure that there are at least one uppercase and one lowercase characters, while using a character set to cover the rest of the allowed characters:

^(?=[a-z0-9!@#$%^&*()+=?]*[A-Z])(?=[A-Z0-9!@#$%^&*()+=?]*[a-z])[A-Za-z0-9!@#$%^&*()+=?]*$ 

Demo: https://regex101.com/r/Uyy1aj/2

Sign up to request clarification or add additional context in comments.

2 Comments

I want only numbers and special characters to the only other options.
For example, I don't want them to be able to use {

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.