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

Re: Feature request (#b)...(...)<not empty>



On Sat, Feb 25, 2017, at 08:47 AM, Bart Schaefer wrote:
>    ([all-except-fg-or-bg]|[fg]|[bg])#([fgbg]|[bgfg]|[fg]|[bg])
> 
> Zsh's scanner will always take the left branch of an alternation if both
> branches will succeed, so arranging this with longest matches first will

Yes and this is interesting, I think I'm about something similar:

% a="abc"; echo ${a//(#b)ab(c)(#c0,1)/x} ${a//(#b)ab(c|)/x}
${a//(#b)ab(|c)/x} "<- last one shows | isn't greedy"
x x xc <- last one shows | isn't greedy
% [[ abc = ab(|c) ]] && echo "I've tried multiple options"
I've tried multiple options

I'm not sure if regexes work this way.. Maybe I'm loosing it for a
moment, but:

[[ abc =~ ab(|c) ]] && echo "I've tried multiple options"
zsh: failed to compile regex: empty (sub)expression

not sure how to test regexes. My point is:
- having | in parentheses behave this way looks like something
implementation-driven, not finite automata driven,
- allowing principle of greediness to be deliberately not followed
creates more rich behavior

Maybe (#n) can be implemented this way, by looking at code and not
following model. To in result extend number of states (number of
behaviors) of the system.

-- 
Sebastian Gniazdowski
psprint2@xxxxxxxxx



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