The password must be between 6 and 10 digits, and the first character is required to be an uppercase letter, and a regular expression with at least one-sharp special symbol is required in the password.

needs to do a form verification, the requirements are as follows:
password must be between 6 and 10 digits, and the first character is required to be an uppercase letter, and the password needs at least one-sharp symbol
to come up with the answer after thinking about it for a long time.

^ Amurz [0-9a-zA-Z] {5pm 9}

this is close to success, but the problem is also obvious

^ Amurz {5pm 9}

this does not contain at least one condition, so it is OK not to write-sharp.

ask the master for advice, thank you!


/^(?=[A-Z].{5,9}$)(?=.*-sharp.*$)/.test('A12345-sharp-sharp-sharp-sharp1')

what I write here is 6-10 digits, starting with an uppercase letter, including-sharp,. There are no restrictions on special characters. If you want to limit them, you can modify them by yourself.


/ ^ [Amurz] / begins with an uppercase letter
/ ^ [Amurz] [\-sharpa-Z0-9] {5 sharpa-Z0 9} / try
later, I can only think of using a stupid method to carry out | or operation, and I hope you don't know much about the rules. I hope you can find a better way.


^(?=.*-sharp)[A-Z][a-zA-Z\d-sharp]{5,9}$

Click to see the match

Menu