Replace all /for which there are /lower in the chain; so it excludes the last/
perl -wE'$_ = q(a/b/c/d/e); s{/(?=.*?/)}{.}g; say'
It uses positive "outlook" , (?=...)to assert the presence of /further (after .*?), without consuming anything.
- ( ) / "lookahead"
s{/([^/]*)(?=/)}{.$1}g;
, , / "" , . ([^/]*) ( ), (.*? ).
: 126% v5.10.1 v5.27.2 ( ) 110% v5.16.1 ( ). 4-10 .
ikegami , , .
share