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

Re: non-greedy matching?



Adam Spiers <adam@xxxxxxxxxx> wrote:
> They are done in order to strip control characters from a prompt so
> that its display width can be determined.  At first I thought that it
> would surely be easy to avoid this, but I still haven't come up with a
> quick replacement, since neither zsh nor sed seem to be able to do
> non-greedy matching.

You can, it's in the manual.

% foo='%{one%}hello%{two%}'
% print ${(S)foo//[%]\{*[%]\}}
hello

Don't ask me why you need to put the `%' in square brackets --- there may
be some stray (s)printf in the code, for example.  (Do tell me if you know
what it is.)

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070



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