From ba22472b7f16b696cc4251fab090652d31308e66 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 1 Aug 2006 17:35:17 +0000 Subject: 22573: smooth interface to history-beginning-search-menu document how to quote metacharacters for reverse array subscript --- Doc/Zsh/params.yo | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Doc/Zsh/params.yo') diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index 9212f8593..fe005ed21 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -211,6 +211,18 @@ example (assuming the option tt(KSH_ARRAYS) is not in effect): example([[ ${array[(i)pattern]} -le ${#array} ]]) If tt(KSH_ARRAYS) is in effect, the tt(-le) should be replaced by tt(-lt). + +Note that in subscripts with both `tt(r)' and `tt(R)' pattern characters +are active even if they were substituted for a parameter (regardless +of the setting of tt(GLOB_SUBST) which controls this feature in normal +pattern matching). It is therefore necessary to quote pattern characters +for an exact string match. Given a string in tt($key), and assuming +the tt(EXTENDED_GLOB) option is set, the following is sufficient to +match an element of an array tt($array) containing exactly the value of +tt($key): + +example(key2=${key//(#m)[\][+LPAR()+RPAR()\\*?#<>]/\\$MATCH} +print ${array[(R)$key2]}) ) item(tt(R))( Like `tt(r)', but gives the last match. For associative arrays, gives -- cgit 1.4.1