简体   繁体   中英

How to check bigger than or smaller than a number by regex?

I have a Drupal module which allow regex check of a text field. To check a valid birth year of 4+ years old, the valid range is year 1900 to 2006.

So assume the input string must be 4-char long. What's the regex to check the string is in that range? Thanks!

这应该可以解决问题:

"^(19[0-9]{2}|200[0-6])$"

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM