views:

39

answers:

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!

+8  A: 

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.

R0MANARMY
the `{n,m}` construct means "a minimum of n and a maximum of m of the following block" so it reads as "anything 0-9 1 to 3 times"
Erik
Thank-you, that worked perfectly and the link you provided is also very helpful.
letseatfood
@letseatfood: Regex can be a powerful friend in some situations and in the past I've found that site to be quite helpful.
R0MANARMY