Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: help with regex

by ExReg (Priest)
on Mar 08, 2016 at 23:35 UTC ( [id://1157127]=note: print w/replies, xml ) Need Help??


in reply to help with regex

Or, expanding on what choroba said,

$test =~ s{^/+}{/};

if, for some perverse reason, you have more than two //, like $test = "////user/";

Replies are listed 'Best First'.
Re^2: help with regex
by Your Mother (Archbishop) on Mar 09, 2016 at 00:34 UTC

    It's probably a nice addition but I find regexes that can work while leaving the original unmodified irksome. $test =~ s{^/+}{/} will work on /something and leave it identical. I would rather see $test =~ s{^//+}{/}; so the intent is clear and action is only taken when necessary.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-18 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found