regexp pipe problems..



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

.



Relevant Pages

  • Re: regexp pipe problems..
    ... I have a "fairly" straightforward regular expression which grabs ... Please see the posting guidelines for this group to learn how you can ... Sinan Unur ...
    (comp.lang.perl.misc)
  • Re: what is regular expression
    ... > I want to know what is mean by regular expression in C ... It has to do with the lack of facial grimaces following a long bout ... the broken "Reply" link at the bottom of the article. ... Prev by Date: ...
    (comp.lang.c)
  • Re: Regular Expression help!
    ... >Is it possible by using Regular expression? ... Canadian Mind Products, Roedy Green. ... http://mindprod.com Again taking new Java programming contracts. ... Prev by Date: ...
    (comp.lang.java.programmer)
  • Re: number of spaces in a given sentence using regular expression.
    ... Write a perl script to find the number of spaces in a given sentence using regular expression. ... Paul Johnson - paul@xxxxxxxx ... Prev by Date: ...
    (perl.beginners)
  • Re: Create DFA from regular expression
    ... >>From Paminu ... >>Is it possible to create a DFA directly from a regular expression or necessary to ... Mistake: that should read: ... Prev by Date: ...
    (comp.theory)