Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wrong array range with (r) flag on scalar?
- X-seq: zsh-workers 34657
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: wrong array range with (r) flag on scalar?
- Date: Thu, 05 Mar 2015 17:06:38 +0000
- In-reply-to: <150305084408.ZM20963@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <20150305083000.GA3294@localhost.localdomain> <150305084408.ZM20963@torch.brasslantern.com>
couldn't resist rubbing it in at the end :-)
pws
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index d044f87..7b127bc 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -187,7 +187,17 @@ from the end of the array tt(foo), and
Subscripting may also be performed on non-array values, in which
case the subscripts specify a substring to be extracted.
For example, if tt(FOO) is set to `tt(foobar)', then
-`tt(echo $FOO[2,5])' prints `tt(ooba)'.
+`tt(echo $FOO[2,5])' prints `tt(ooba)'. Note that
+some forms of subscripting described below perform pattern matching,
+and in that case the substring extends from the start of the match
+of the first subscript to the end of the match of the second
+subscript. For example,
+
+example(string="abcdefghijklm"
+print ${string[+LPAR()r+RPAR()d?,+LPAR()r+RPAR()h?]})
+
+prints `tt(defghi)'. This is an obvious generalisation of the
+rule for single-character matches.
subsect(Array Element Assignment)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author