W
willwade
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
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