about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-03-06 09:50:01 +0000
committerPeter Stephenson <pws@zsh.org>2015-03-06 09:50:01 +0000
commit00b3085b969f46370f7cde28e9dfa10026b884c7 (patch)
treece386e0b57828a13b8db40c4902d00489f14d90a
parentec03a233c5b1ae0256f00bfa6bf19d406d860d33 (diff)
downloadzsh-00b3085b969f46370f7cde28e9dfa10026b884c7.tar.gz
zsh-00b3085b969f46370f7cde28e9dfa10026b884c7.tar.xz
zsh-00b3085b969f46370f7cde28e9dfa10026b884c7.zip
34657: document the effect of substring subscripting better
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/params.yo12
2 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 74295288f..4f9f92886 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-06  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 34657: Doc/Zsh/params.yo: document the effect of substring
+	subscripting better.
+
 2015-03-05  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 34654: Completion/Redhat/Command/_rpm: complete absolute file
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index d044f8749..7b127bc68 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)