Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Regex help

by daxim (Chaplain)
on Jul 12, 2013 at 10:35 UTC ( #1043941=note: print w/ replies, xml ) Need Help??


in reply to Regex help

Don't use regex when a specialised parsing module exists.

use 5.010; use URI; use List::MoreUtils qw(first_index); for my $uri (qw( http://www.chi.com/business/world/us-microsoft-reorganization.stor +y http://www.chi.com/business/sns-rt-us-markets-stocks.story http://www.chi.com/business/sns-rt-us-bank-capital-us.story http://www.chi.com/business/sns-rt-us-bank-capital.story )) { say $uri; my @segments = grep { $_ } URI->new($uri)->path_segments; say for splice @segments, 0, (first_index { /-/ } @segments); }


Comment on Re: Regex help
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043941]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2015-07-08 04:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls