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.