0

Suppose I want only digital/numeric value (No Special character or alphabet)

So, the regular expression will be ^[0-9]

If I want a fix length of 6, what regular expression I should use?

Example: 555333, 111222

BlackCat
  • 1,724
  • 2
  • 14
  • 35

1 Answers1

7

Try ^[0-9]{6}$

  • ^ beginning
  • [0-9] digit 0 to 9 (alternatively you could use [\d])
  • {6} appears exactly 6 times
  • $ end of string
fubo
  • 42,334
  • 17
  • 98
  • 130