Regular Expressions For 4 Or 6 Digits

Category: Numbers

Regular Expressions that exactly match 4 or 6 digits, which are typically used in Pin Code.

4 Digits Regex:

/^[0-9]{4}$/

6 Digits Regex:

/^[0-9]{6}$/

See Also:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.