Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Issue with ${var#(*_)(#cN,M)}



Original problem
> } ~$ a='1_2_3_4_5_6'
> } ~$ echo ${a#(*_)(#c2)}
> } 2_3_4_5_6

On Tue, 20 Oct 2015 16:04:22 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> What's messing it up is the "*" operator and the backtracking that is
> implied because * can match anything.

Exactly.  What's backtracking over what in what order here is a bit of
nightmare, and I'm not sure I'm likely to get my mind round it.

Unless someone does, you'll be better of sticking to

% a='1_2_3_4_5_6'
% echo ${a#([^_]#_)(#c2)}
3_4_5_6

and then we don't have the "*" within the group to worry about.

pws



Messages sorted by: Reverse Date, Date, Thread, Author