Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: backreferences



On Fri, Oct 16, 2015 at 9:37 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> On 10/16/2015 05:35 AM, Bart Schaefer wrote:
>>
>    test2 ()
>    {
>    match=
>    sstring="abcdeedcbaabcde"
>    # Bart doesn't like:
>    #if [[ "$sstring" = (#b)([(^(edcba))]*)(edcba)(*) ]];
>    # Bart likes:
>    if [[ "$sstring" = (#b)(^edcba)(edcba)(*) ]];
>
>    then
>       echo "\nIt's a poyfect match\n"
>    fi
>
>    echo "one   $match[1]"
>    echo "two   $match[2]"
>    echo "three $match[3]"
>    echo "four  $match[4]"
>    echo "five  $match[5]"
>    }
>
>    It's a poyfect match
>
>    one   abcde
>    two   edcba
>    three abcde
>    four
>    five
>
> ... match[1]  seems to agree with your previous interpretation, no?

Only seems to.  Try sstring="edcbaabcdeedcbaabcde" and I don't think
you'll get the result you expected.

>> This needs to be (#b)(^edcba*)(edcba)(*)
>
> That produces identical output as well, so what's the diff? Probably one of
> those things that blows up in your face one day ...

Something like that , yeah.

>>      EGREP      ZSH
>
> Is a complete table available somewhere?

There might be something in the Bash to Zsh book -- I don't have it
handy to confirm.



Messages sorted by: Reverse Date, Date, Thread, Author