Regex for digits only

I thought this regex would only allow 3 digits (numbers)

/^\d{3}$/

How do I convert it so that only 3 digits are in it?

Try using a character class
/^[\d]{3}$/

1 Like

can you show an example where that fails?

oh, it worked, just a stupid syntax error

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.