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, 7 Nov 2018 at 16:25, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> 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.

It now works, thanks!

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org



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