Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Regex output incorrect

by jakeease (Friar)
on Dec 14, 2010 at 10:41 UTC ( [id://877044]=note: print w/replies, xml ) Need Help??


in reply to Regex output incorrect

In your regex, the the dot matches any character, and in particular, it matches the slash before 2010. That's the first character that you don't want, so one way to get the correct output is to capture everything up to there:

use strict; use warnings; my $folder_path = "/aboutiso/corp_gov/bod/agendas/2010"; $folder_path =~ s#((/\w+)+)/\w+$#$1#; print "folderpath: $folder_path\n";
I replaced the dot with a slash since that's the first character I don't want.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found