There are three approaches I can think of that would solve your issue, and only one is a regex.
$xpath =~ s{/[^/]+$}{};
my @temp = split('/', $xpath); $xpath = join('/',@temp[0..$#temp-1]);
$xpath = substr($xpath,0,rindex($xpath,'/'));
The last one (rindex) strikes me as the most efficent way to go, but I haven't Benchmarked it.
In reply to Re: Regex: Matching last of repeated character to end of string
by radiantmatrix
in thread Regex: Matching last of repeated character to end of string
by loris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |