Re: regexp pipe problems..



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
.



Relevant Pages

  • Re: Good Scientific News for Creatioists
    ... '' The wood, often referred to as níspero, is uniform in its ... structure--it does not show annular growth rings. ... Cultivation within a plantation setting results in trees ... The small trees, though, cannot be tapped for chicle. ...
    (uk.philosophy.atheism)
  • Re: one day well all be playing plastic resin guitars
    ... global warming make it impossible to grow trees. ... Wood and corn are all renewable resources. ... The demand for wood was lower than that of today and the demand will ...
    (alt.guitar)
  • Re: one day well all be playing plastic resin guitars
    ... global warming make it impossible to grow trees. ... Wood and corn are all renewable resources. ... The demand for wood was lower than that of today and the demand will ...
    (alt.guitar)
  • Re: Wal-Mart awards $2 billion to U.S. hourly employees
    ... I think the average Walmart wage is no more than $10 an hour. ... Last November lightening struck one of our trees at the back of the ... Elm was a desirable wood and I think that destruction of otherwise healthy trees was misinformed. ... There are also several companies now that salvage wood that is submerged in rivers and lakes, sometimes for a century or more. ...
    (soc.retirement)
  • Re: one day well all be playing plastic resin guitars
    ... global warming make it impossible to grow trees. ... Wood and corn are all renewable resources. ... The demand for wood was lower than that of today and the demand will ...
    (alt.guitar)