help-bash
[Top][All Lists]
Advanced

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

Re: Regex and glob patterns in Parameter Expansion


From: alex xmb ratchev
Subject: Re: Regex and glob patterns in Parameter Expansion
Date: Sun, 19 Mar 2023 16:17:40 +0100

On Sun, Mar 19, 2023, 4:07 PM uzibalqa <uzibalqa@proton.me> wrote:

>
>
>
> ------- Original Message -------
> On Monday, March 20th, 2023 at 2:44 AM, alex xmb ratchev <
> fxmbsw7@gmail.com> wrote:
>
>
> >
> >
> > On Sun, Mar 19, 2023, 2:20 PM uzibalqa <uzibalqa@proton.me> wrote:
> >
> > >
> > > Does Shell Parameter Expansion accept regex or glob patterns?
> > >
> > > ${str/$ptrn/}
> > >
> > > ${str##$ptrn}
> > >
> > > ${str%%$ptrn}/}
> >
> >
> > they accept , if not quoted , glob s
>
> What instances would one pass quoted patterns ?
>

simply , if its static data , quote it , to not make accidental glob matches
if its a glob or part of a glob , dont quote
to make bash parse the glob

again , "quoted static strings" and @(some_match)

m1=' a @(test) string ' m2='@(some_match)'

${str/"$m1"}
${str/$m2}

same applies to inside [[ test

[[ $var == "exact text match" ]]
[[ $var == "$m1" ]]
[[ $var == $m2 ]]


reply via email to

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