How should I write regex to validate below conditions:
eg: Valid strings: 1234, EC123, 1YC898, 001234
So far, I have tried below regex, but seems like I am missing something?
(^[a-zA-Z0-9]{4,6})?\d{3}$
You can use:
^[a-zA-Z0-9]{1,3}\d{3}$
^[a-zA-Z0-9]{1,3}
will match 1 to 3 alpha-numerals at the start \\d{3}$
will match 3 digits at the end of your input
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.