Thanks. One thing I still can't quite wrap my mind around is a scenario where ${(j.|.)~array} and ${~j.|.)array} would behave differently. I assume it would involve some additional modifications made to $array; I tried something like array=(foo bar) [[ "?" = ${(~j.|.)array:s/foo/?/} ]] # match [[ "?" = ${(j.|.)~array:s/foo/?/} ]] # match but that was not sufficient. On Wed, Sep 3, 2014 at 11:44 AM, Bart Schaefer wrote: > On Sep 3, 10:58am, Clint Hepner wrote: > } > } My reading of the ~ flag leads me to believe that you can replace the > } literal string with a pattern, so that > } > } % print -l ${(~s.[12].):-a1b2c} > } a > } b > } c > > No, that's not what the flag means. It means that after the expansion > of the parameter has been completed, any pattern characters inserted > into the result are active (i.e., not considered quoted). It doesn't > otherwise change the operation of the other flags themselves. > > This doesn't have any effect for the (s) flag because (s) removes > characters from the result, rather than inserting them. > > The purpose of the (~) flag is really to work with the (j) flag, so > that you can create a pattern from an array without having any other > pattern characters in the values of the array also become active. > It also works with (l) and (r), though the uses for treating padding > as pattern characters are pretty obscure. > > To use a pattern for processing the value during expansion, you need > to use the trailing // notation, e.g. > > % print -l ${=${:-a1b2c}//[12]/ } > > or > > % print -l ${(s:1:)${:-a1b2c}//[12]/1} >