help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pattern matching declaration with *(pattern-list)


From: Jesse Hathaway
Subject: Re: Pattern matching declaration with *(pattern-list)
Date: Tue, 7 Jun 2022 13:34:42 -0500

On Tue, Jun 7, 2022 at 1:14 PM goncholden via <help-bash@gnu.org> wrote:
>
> When matching zero or more occurrences of the given pattern-list with
>
> *(pattern-list)
>
> what in the declaration of using opening and closing parenthesis called?

extglob, from `man bash`:

If the extglob shell option is enabled using the shopt builtin, several
extended  pattern  matching operators are recognized.  In the following
description, a pattern-list is a list of one or more patterns separated
by a |.  Composite patterns may be formed using one or more of the fol‐
lowing sub-patterns:

       ?(pattern-list)
              Matches zero or one occurrence of the given patterns
       *(pattern-list)
              Matches zero or more occurrences of the given patterns
       +(pattern-list)
              Matches one or more occurrences of the given patterns
       @(pattern-list)
              Matches one of the given patterns
       !(pattern-list)
              Matches anything except one of the given patterns

Complicated extended pattern matching against long strings is slow, es‐
pecially when the patterns contain alternations and the strings contain
multiple matches.  Using separate matches against shorter  strings,  or
using arrays of strings instead of a single long string, may be faster.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]