Ruchi yadav Ruchi yadav - 5 months ago 15
Javascript Question

Regular expression for alphanumeric in Angularjs

I want a regex for alphanumeric characters in angularJS, I've tried some regex like "(\d[a-z])" but they allow me to enter only number as well as only alphabets. But I want a regex which won't allow me to enter them.

Example:
121232, abchfe, abd()*, 42232^5$ are some example of invalid input.
12fUgdf, dGgs1s23 are some valid inputs.

Answer

This one requires atleast one of each (a-z, A-Z and 0-9):

^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])([a-zA-Z0-9]+)$