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

Re: Match to the end of string when using (S) flag



On Wed, Nov 7, 2018 at 4:30 AM Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> % text='# This is an example code that is diverse and allows to test a'
> % local last=""; : ${text//(#b)([a-d])/${last=${match[1]}}}; print -rl $last
> <empty result>
>
> With #m:
> % local last=""; : ${text//(#m)([a-d])/${last=$MATCH}}; print -rl $last
> <empty result>
>
> How come it works for you?

In your expression, $last already has a value (empty string), so you
need ${last::=$match[1]} or ${last::=$MATCH} to assign it.



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