Re: regexp pipe problems..
- From: Simon Taylor <simon@xxxxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 17:34:09 +1000
Hello Will,
OK, I have a "fairly" straightforward regular expression which grabs
some bits out of a url. Now this should be easy but I can't see the
wood for the trees.
[snip]
and it prints:
yay! sub1.site3.org,,,sub1,
when I want to print:
yay! sub1,slashey3,39,4,223
Actually, when I run the code you've posted it prints
poo
The code below uses split() to get the following output:
sub1.site3.org slashey3 39 4 223
So depending on your needs, this might be adequate, (though you'd need to handle the "sub1.site3.org" string as an extra step).
#!/usr/bin/perl use strict; use warnings;
my $url = 'http://sub1.site3.org/slash/slashey2/slashey3/39/4/223';
my @matches = (split m:/:, $url)[2,5..8]; print "$_\n" for @matches;
__END__
Regards,
Simon Taylor .
- References:
- regexp pipe problems..
- From: willwade
- regexp pipe problems..
- Prev by Date: Re: Copy local Groups -- Get SID
- Next by Date: Re: Looking for combination.pm
- Previous by thread: Re: regexp pipe problems..
- Next by thread: Re: regexp pipe problems..
- Index(es):
Relevant Pages
|
|