javascript regex requiring at least one letter, one number and prevents from adding certain words

Viewed 1469

I'm trying to modify my regex which requires user to type at least one letter and one digit which looks like this :

new RegExp('^(?=.*[a-z])(?=.*[0-9]).+$')

And I want to prevent user from using certain words like email address part before @.

So let's assume the email address is example@example.com

I want to force user to use a string that doesn't contain example in it (any part of the string)

This is what I have so far:

\b(?:(?!example)\w)+\b

But it doesn't really force the user to use at least one character and one digit.

When I'm trying to restric it I'm ending up with this:

\b(?:(?!example).*[a-z].*[0-9])+\b

But now the strings must follow the order of example then a [a-z] and then [0-9]

Any help greatly appreciated

Thanks!

1 Answers
Related