Crocsx
Crocsx

Reputation: 7609

REGEX : Must include only letter,number or character

I have the following REGEX

/^(?!.* )(?=.*[!@#$\.%^&])(?=.*\d)(?=.*[A-Za-z])$/

it should not allow white space and contains a letter a digit and a character.

But I would like to have the following

do not contain space, and contains any of [!@#$\.%^&], digits and character, so aaaaaaaa or !!!!!!!! would work.

but I can7t find how to validate the lot

Upvotes: 2

Views: 72

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133458

With your shown samples, could you please try following. Here is Online regex demo

^[!#$a-z.%^&\dA-Z@]+$

Explanation: Simply looking for !#$a-z.%^&\dA-Z@ characters from starting to end of the string if only these come then match the string if anything else is coming apart from these then don't match the string.

Upvotes: 2

Related Questions