zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Sebastian Gniazdowski <psprint2@fastmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: Feature request (#b)...(...)<not empty>
Date: Sat, 25 Feb 2017 15:13:15 +0000	[thread overview]
Message-ID: <20170225151315.GA4424@fujitsu.shahaf.local2> (raw)
In-Reply-To: <1488011830.2241447.892433784.52D183B6@webmail.messagingengine.com>

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
     7

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.

Cheers,

Daniel


  reply	other threads:[~2017-02-25 15:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25  8:37 Sebastian Gniazdowski
2017-02-25 15:13 ` Daniel Shahaf [this message]
2017-02-25 15:36   ` Sebastian Gniazdowski
2017-02-25 16:47     ` Bart Schaefer
2017-02-25 17:24       ` Sebastian Gniazdowski
2017-02-25 17:54         ` Daniel Shahaf
2017-02-25 20:38         ` Bart Schaefer
2017-02-25 17:54       ` Sebastian Gniazdowski
2017-02-25 21:05         ` Bart Schaefer
2017-02-25 22:52           ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170225151315.GA4424@fujitsu.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=psprint2@fastmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).