-3

I would like to limit a string of numbers to 14 digits, and require that the first 5 digits are: 26173. The rest of the digits can be any number between 1-9. Example: 26173000740380.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
zen55q
  • 1

1 Answers1

0

The regexp 26173\d{9} specifies the first 5 characters must be 26173 and the following 9 characters must be any decimal number \d.

If the remaining 9 characters must be between 1 - 9 you could use 26173[1-9]{9}. Both examples are using java regexp syntax.

Regexp planet is a good site for testing regular expressions

https://www.regexplanet.com/advanced/java/index.html

httPants
  • 1,832
  • 1
  • 11
  • 13