On 22 December 2010 19:51, David Korn <[email protected]> wrote: > cc: [email protected] > Subject: Re: [ast-users] I thought .sh.match would have the things that had > been matched > -------- > > >> AST Users, >> >> I thought the array ".sh.match" would have the things that the substitution >> (whi >> ch worked) had matched. Why didn't it? >> >> x=',sns567:MCOMRE-9952;sns2345' >> print -r -- "#--------------- x: $x" >> y="${x//+([,:;])/^}" >> print -r -- "#--------------- y: $y" >> for i in "${!.sh.match[@]}"; do print -r -- "<${.sh.match[i]}>"; done >> #--------------- x: ,sns567:MCOMRE-9952;sns2345 >> #--------------- y: ^sns567^MCOMRE-9952^sns2345 > > > The .sh.match array returns the array of matches for subpatterns contained > in (...). > > With //, you are doing multiple matches on a pattern so > .sh.match should have contained the last match on the pattern. > it should have output ;. The fact that it didn't do this is a bug. > > Now, an alternative would be to use a two dimensional array > .sh.match[pattern#][match#] > > For the / operator match# would always be 0. > pattern# would be the number of (...) in the pattern. > > I will add this to my list of things to resolve in a future > release.
Could this be made available in the next beta as SHOPT_ build configuration flag? Wendy _______________________________________________ ast-users mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-users
