Regular expression to allow for number values between 1

In my .htaccess file I have the following rule:

RewriteRule ^gallery/[0-9][0-9][0-9]/$ index.php?gallery_id=$1

It allows for any number that is three digits in length. I do not know how to allow for less than three digits as well (or more than three for that matter).

I am still new to regex.

Thank-you!


You want to do something along the lines of

[0-9]{1,3}

There are some excellent examples here. Scroll down to nearly the bottom of the page, there are examples of how the various range selections (not the right term for them) work.

链接地址: http://www.djcxy.com/p/86988.html

上一篇: 正则表达式:如何只允许大于零的整数

下一篇: 正则表达式允许数字值在1之间