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: 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: Morning Watch Smoke; January 24, 2006
    ... Steven...I once saw a 4000 year old living Bristlecone Pine in the ... White Mts. ... trees and an above ground pool. ... > It was a double waste to burn the wood, ...
    (alt.smokers.pipes)