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).
\d for single or multiple digit numbers To match any number from 0 to 9 we use \d in regex. It will match any single digit number from 0 to 9. \d means [0-9] or match any number from 0 to 9. Instead of writing 0123456789 the shorthand version is [0-9] where [] is used for character range.
[] denotes a character class. () denotes a capturing group. (a-z0-9) -- Explicit capture of a-z0-9 . No ranges.
\\. matches the literal character . . the first backslash is interpreted as an escape character by the Emacs string reader, which combined with the second backslash, inserts a literal backslash character into the string being read. the regular expression engine receives the string \. html?\ ' .
The Match-zero-or-more Operator ( * ) This operator repeats the smallest possible preceding regular expression as many times as necessary (including zero) to match the pattern.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With