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,932
  • 3
  • 19
  • 47

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
  • 44,811
  • 17
  • 103
  • 137