Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${name/pattern/repl} with negated pattern
# p.stephenson@xxxxxxxxxxx / 2014-05-15 16:32:19 +0100:
> ^ means "anything, and I do mean anything, that doesn't match the
> following pattern". You can see that the initial "x" doesn't match the
> pattern, because the pattern requires the "/" to match. However, x/ or
> anything longer does match the pattern because of the *. So the longest
> string at the head that doesn't match the pattern is "x". So it removes
> that.
thanks, i suspected strongly it was my confusion with the negation.
i'll have to go and get some practice with pattern matching, i used to
do better. and your suggestion of #% is spot on, it does fix it.
> I think you'd be better off with ${a:#^x/*},
agreed.
> So try ${(M)a:#x/*}.
yep, this is IMO easiest.
--
roman
Messages sorted by:
Reverse Date,
Date,
Thread,
Author