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

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



On Tue, 1 Nov 2016 at 22:29, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> You can do this with just a counter, you don't need a math function:
>
>   i=$#region_highlight
>   : ${text//(#mi)(${~colsearch_pattern})/
>       ${region_highlight[++i]=$((offset + MBEGIN))}
>       ${region_highlight[++i]=$((offset + MEND))}
>       ${region_highlight[++i]=${__hsmw_hl_color}}}

% 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?
-- 
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