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

Re^6: You won't believe what this regular expression does!

by haukex (Bishop)
on Feb 26, 2021 at 13:16 UTC ( #11128830=note: print w/replies, xml ) Need Help??


in reply to Re^5: You won't believe what this regular expression does!
in thread You won't believe what this regular expression does!

In real life, those lines were paths, and I wanted all of then ending in a single slash.

Ah, I see. You want canonpath from File::Spec ;-) (doesn't add the trailing slash, but there are multiple possible solutions for that as well)

And this is admittedly not the prettiest solution, but it works: s{(?| /* (\n) | /+ (\z) | [^/] \K (\z) )}{/$1}mgrx. Or just split the input string on \n...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-07-06 10:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?