views:

40

answers:

2

Hello Experts,

Given the following URIs sample:

 /index.site.rooms.98.html

 /index.site.rates.665678.html  

I need to capture the string which identifies the page with REGEX:

Rooms

Rates

Thanks

+1  A: 
$page =~ /^\/index\.site\.(.*?)\.(\d+)\.html$/;
my $room = $1;
my $num = $2;

Perl regex.

Borealid
Thanks for your answer, unfortunately. I am not using Perl, this is for Google Analytics and it will replace matched string on the fly. Is there a way to store one string under $1 using plain regular expressions?
Matias
@Matias After a quick search it seems GA uses perl compatible regular expressions (PCRE), not all features are supported but this should work.
Neil Aitken
Well, you could chop off the first and last bits with two regexes:`s/^\/index\.site\.//``s/\.html$//`
Borealid
I am not sure, in fact, its quite limited what you can do. There are two input boxes, one for Search for and another to Output >. I imagine there should be some kindof built-in variables to use but not sure.
Matias
@Borealid -- Mate, great idea !!! i will apply two filters !!
Matias
A: 

try this: (rooms|rates).[0-9]+

Eric