zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: file globbing
Date: Thu, 5 Aug 2021 16:36:48 +0100 (BST)	[thread overview]
Message-ID: <600156803.688994.1628177808803@mail2.virginmedia.com> (raw)
In-Reply-To: <112137895.688578.1628177238255@mail2.virginmedia.com>

> On 05 August 2021 at 16:27 Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> > On 05 August 2021 at 16:14 Ray Andrews <rayandrews@eastlink.ca> wrote:
> > Say I have these files:
> > 
> >       0 [2021-08-05--07:58] d,1
> >       0 [2021-08-05--07:59] d,1,first
> >       0 [2021-08-05--07:59] d,1,second
> > 
> > I want a glob that captures them all but:
> > 
> >      $ print -l d,1[^[:digit:]]*(N)
> >      d,1,first
> >      d,1,second
> 
> Yes, indeed it looks like this is available by default (you don't even need EXTENDED_GLOB).
> 
> d,1([^[:digit:]]*|)(N)
> 
> The (either_this|or_that) matches either what you originally said or nothing ("or_that" here is empty).
> 
> There are other ways of doing it, and there's a ksh/bash-compatible way, too, but that's probably
> the one I'd immediately reach for.

Actually, come to think of it, I can't resist mention one other one, since it keeps the squiggles
to a bare minimum, though this *does* require "setopt extendedglob".

d,1^[[:digit:]]*

That means "d,1" following by anything that doesn't match the pattern after the "^".  Caution
needs to be exercised with more complicated uses of "^", though --- negative match assertions
can be really counterintuitive.

pws


  reply	other threads:[~2021-08-05 15:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05 15:14 Ray Andrews
2021-08-05 15:27 ` Peter Stephenson
2021-08-05 15:36   ` Peter Stephenson [this message]
2021-08-05 16:05     ` Ray Andrews
2021-08-05 16:48       ` Vincent Lefevre
2021-08-05 18:22         ` Ray Andrews
2021-08-05 18:53           ` Bart Schaefer
2021-08-05 17:52       ` Lawrence Velázquez
2021-08-08 15:07       ` Stephane Chazelas
2021-08-08 16:19         ` Ray Andrews
2021-08-08 18:28           ` Lawrence Velázquez
2021-08-08 22:24           ` Vincent Lefevre
2021-08-09  0:41             ` Ray Andrews
2021-08-09 10:46             ` Stephane Chazelas
2021-08-05 15:49   ` Ray Andrews

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=600156803.688994.1628177808803@mail2.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@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).