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

Re: PATCH: fix for (#s) and (#e) in param substs



> Peter Stephenson wrote:
> >By the way, I inserted a hostage to fortune in the manual by claiming that
> >`(^(#s))' etc. also work, i.e. you can assert that you are not at the start
> >of the string.
> 
> Careful.  If that's been implemented correctly, `(^(#s))' will match
> an arbitrarily long substring anywhere, in addition to a zero-length
> substring anywhere other than the start of the string.

Yes, this was at the back of my mind but I didn't really work it all out.
(''~(#s)) works, though is a bit clumsy.

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.5
diff -u -r1.5 expn.yo
--- Doc/Zsh/expn.yo	2000/04/14 11:49:31	1.5
+++ Doc/Zsh/expn.yo	2000/04/14 13:01:06
@@ -1318,7 +1318,10 @@
 provides a single simple and memorable method.
 
 Note that assertions of the form `tt((^(#s)))' also work, i.e. match
-anywhere except at the start of the string.
+anywhere except at the start of the string, although this actually means
+`anything except a zero-length portion at the start of the string'; you
+need to use `tt((""~(#s)))' to match a zero-length portion of the string
+not at the start.
 )
 enditem()
 
-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070



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