You don't want a Perl regular expression. You want a regular expression that Zeus will understand. Although they might call that PCRE, not even PCRE handles all Perl regular expressions.
Most of the answers here are wrong because they aren't thinking about the different sorts of URLs that you will can get as input.
- Get just the path portion of the URL
- Match against the path portion to find what you need
- Distinguish between paths that end in a filename and those that don't
There are some examples that you can use as a start. I don't use Zeus and don't want to, so the next part is up to you:
I've read that you can pass the request to a Perl program through Perl Extensions for ZWS, but I'd be surprised if you needed to do that. If you have to resort to that, I'd use the URI module to parse the URI and extract the path. Once you have that, split up the path into it's components:
use URI;
my $uri = URI->new( ... ); # I don't know how Zeus passes data
my $path = $uri->path;
# undef to handle the leading /
my( undef, @parts ) = split $path, '/';
Once you are this far, you have to decide how you want to recognize something as a directory. If you're mapping directly onto a filesystem structure, that is just a matter of popping elements off @parts
until you find the directories, then counting back the number you want to skip.
However, I cringe at doing that, no matter what I put in the Perl program. I'd try really hard to get it done just in the Zeus rules first. Show us what you have so far.