KevySaysBeNice
[H]ard|Gawd
- Joined
- Dec 7, 2001
- Messages
- 1,452
Hi all!
I am going a bit crazy by what I think should be a simple regular expression issue.
Here is the task: we want to take this:
/ts/123/32/1
and rewrite it to
/themes/index.php?t=$1&d=$2&r=$3
except, here is the catch: we want the last parameter to be totally optional. In most cases the final /1 won't be there, so if it's not there we don't want the rewrite rule to break.
Anyway, this is what we have so far and it works to get the first number (123) and the second (32).
/ts.*/(\d+)\/(\d+)$
BUT, I'm not sure how to get the last value, and make it optional.
Anybody have any pro tips?
Thanks in advance!!!
I am going a bit crazy by what I think should be a simple regular expression issue.
Here is the task: we want to take this:
/ts/123/32/1
and rewrite it to
/themes/index.php?t=$1&d=$2&r=$3
except, here is the catch: we want the last parameter to be totally optional. In most cases the final /1 won't be there, so if it's not there we don't want the rewrite rule to break.
Anyway, this is what we have so far and it works to get the first number (123) and the second (32).
/ts.*/(\d+)\/(\d+)$
BUT, I'm not sure how to get the last value, and make it optional.
Anybody have any pro tips?
Thanks in advance!!!