David, is there time to get the .sh.match[pattern#][match#] feature
for the next ksh release? We have encountered many cases where this
could avoid complex loop/if/matching by the more elegant
.sh.match[pattern#][match#] solution.

Olga

On Wed, Dec 22, 2010 at 7:51 PM, 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.
>
>
>
> David Korn
> [email protected]
> _______________________________________________
> ast-users mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-users
>



-- 
      ,   _                                    _   ,
     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
.----'-/`-/     [email protected]   \-`\-'----.
 `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
      /\/\     Solaris/BSD//C/C++ programmer   /\/\
      `--`                                      `--`

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to