Replace the first (.*) with ([^/]*), so it matches like (b)/(c/d) instead of (b/c)/(d) sort of thing.
.* is "greedy"; here's the relevant paragraph from the regex man page:
Quote:
In the event that an RE could match more than one substring of a given
string, the RE matches the one starting earliest in the string. If the
RE could match more than one substring starting at that point, it
matches the longest. Subexpressions also match the longest possible
substrings, subject to the constraint that the whole match be as long
as possible, with subexpressions starting earlier in the RE taking pri‐
ority over ones starting later. Note that higher-level subexpressions
thus take priority over their lower-level component subexpressions.
|