user2881499
user2881499

Reputation: 1

Need regular expression for atleast 3 alpha numeric values and unlimited numeric values

I need a regular expression which will limit alphanumeric values and unlimited number of numeric values.

  1. At least 3 ALPHANUMERIC values
  2. Unlimited number of NUMERIC values

I have tried this

/^[a-zA-Z]{3,}$/ which will limit characters.

And also

/^\d+$/ which will check for the numeric values ...

But I need to add another condition like unlimited numeric values. I need it in a single regexp.

Upvotes: 0

Views: 290

Answers (1)

JJJ
JJJ

Reputation: 33153

^(\d*[a-zA-Z]\d*){3,}$

Which is three characters a-z surrounded by any amount of numbers, matching strings like "12a34b567c".

To check for alphanumeric (a-z + numbers):

^(\d*[a-zA-Z0-9]\d*){3,}$

And, this is assuming the characters can be in any order (i.e. not starting with 3 alphanumeric characters, followed by numbers only).

Upvotes: 2

Related Questions