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

Re: (r) flag on scalar



On Mar 9,  7:38am, Han Pingtian wrote:
} Subject: (r) flag on scalar
}
} I think below command line should give result "bc", but:
} 
} localhost% s=abcdefg
} localhost% print $s[(r)bc]
} b
} localhost%
} 
} Looks like this isn't intuitional.

$s[(r)bc] is a single index, so it's the index where the first match for
"bc" begins.

$s[(r)bc,(r)ef] is a range of indices, so it begins where "bc" begins and
ends where "ef" ends.

The only thing not quite intuitive about this is that a wildcard (either
* or with extendedglob ?# ) at the end of the ending patterrn is not
considered part of the match for (r) but is part of the match for (R).
PWS's latest doc tweak still doesn't explicitly describe that.



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