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

Re: non-greedy matching?



> % 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.)

I just realised: //% means match only at the end.
  % print ${(S)foo//\\%\{*[%]\}}
also works.  I always loathed that syntax: it's unmemorable and hacky (all
right, it's not on its own).

-- 
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