[TAG] Need a shell regex; having problems

Thomas Adam thomas_adam at bonbon.net
Thu Jun 3 00:42:06 MSD 2004


On Wed, 2 Jun 2004 16:38:10 -0400
"Jay R. Ashworth" <jra at baylink.com> wrote:

> On Wed, Jun 02, 2004 at 04:31:59PM -0400, Ben Okopnik wrote:
> > echo ???.[0-9][0-9][0-9]?([0-9])?([0-9])[abd][abd][abd]
> 
> A*ha*; there *is* a way to make a matchchar optional.  That operator
> is?() -- correct?

Quoting 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 exactly one of the given patterns
              !(pattern-list)
                     Matches anything except one of the given patterns
'''

(I make no apologies for the formatting of that, either)

-- Thomas Adam

-- 
"Annie Hall leaves New York in the end. Press rewind, and Woody gets her
back again." -- "Look Inside America", Blur.





More information about the TAG mailing list