regexp pipe problems..
- From: willwade@xxxxxxxxx
- Date: 29 Jun 2005 23:36:02 -0700
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. I have a few or's in there but it seems to be
adding each to memory - when I only want the found one. Also - instead
of matching just the subdomain it matches the whole domain ($1 see
below) - whats that all about?
$url = 'http://sub1.site3.org/slash/slashey2/slashey3/39/4/223';
if ($url =~ m{(([^/]+).site1.org|([^/]+).site2.org|([^/]+).site3.org)
/slash/slashey2/([^/]+)/([0-9]+)/([0-9]+)/([0-9a-zA-Z-]+)}){
print "yay! $1,$2,$3,$4,$5";
} else {
print "poo";
exit;
}
and it prints:
yay! sub1.site3.org,,,sub1,
when I want to print:
yay! sub1,slashey3,39,4,223
this regular expression stuff makes my head hurt
any help muchly appreciated
:)
will
.
- Follow-Ups:
- Re: regexp pipe problems..
- From: Christian Winter
- Re: regexp pipe problems..
- From: Simon Taylor
- Re: regexp pipe problems..
- From: A. Sinan Unur
- Re: regexp pipe problems..
- Prev by Date: Looking for combination.pm
- Next by Date: Re: regexp pipe problems..
- Previous by thread: Looking for combination.pm
- Next by thread: Re: regexp pipe problems..
- Index(es):
Relevant Pages
|