dotnet-practitioner
dotnet-practitioner

Reputation: 14148

How do I generate regular expression for the following string

I have requirements for the password as follows

  1. at least 6 characters long.
  2. Must have at least one non letter or digit character.
  3. Must have at least one digit ('0'-'9').
  4. Must have at least one uppercase ('A'-'Z').

I don't know how to create a regular expression for the above string requirement.

EDIT: Here is the typical password I could use

Mhal@qat1t

Upvotes: 0

Views: 43

Answers (1)

AMDcze
AMDcze

Reputation: 526

Since you didn't specify which characters it can/cannot have, I made it like this:

^(?=.*?[A-Z])(?=.*?\d)(?=.*?[^\da-zA-Z])\S{6,}$

Upvotes: 1

Related Questions