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.
Asked
Active
Viewed 30 times
-3
-
1Which language are you using? – httPants Sep 09 '21 at 20:46
-
1Does this answer your question? [Learning Regular Expressions](https://stackoverflow.com/questions/4736/learning-regular-expressions) – jonrsharpe Sep 09 '21 at 20:46
1 Answers
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

httPants
- 1,832
- 1
- 11
- 13