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

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

Sebastian Gniazdowski wrote on Sat, Feb 25, 2017 at 00:37:10 -0800:
> Hello,
> found a limitation in regex-like specification, maybe it's easy to add
> extension?
> A pattern: (a|)(b|)(c|). Order of a, b, c matters, but any combination
> of them will be accepted. The problem: |) in all three will also be
> accepted. That's not a combination of a, b, c. This is onset of
> something higher-level: "combination of".
> So maybe: ((a|)(b|)(c|))(#n). #n is for not-empty, resembles [[ -n.
> It looks like typical pattern situation: try something, decide if to
> reject it. So maybe it's easy to add?

Some regexp flavours support zero-width lookahead, which would allow
this.  For example, in Perl,

     % print -l {a,}{b,}{c,} | perl -lnE 'print if /(?=.)(a|)(b|)(c|)/' | wc -l

However, I have no opinion as to whether that should be added: I don't
know how much effort would be involved, and for the given example there
are alternative solutions that require no syntax changes.



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