bug-bash
[Top][All Lists]
Advanced

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

Re: Regular expression matching fails with string RE


From: Clark WANG
Subject: Re: Regular expression matching fails with string RE
Date: Wed, 17 Oct 2012 09:13:06 +0800

On Wed, Oct 17, 2012 at 5:18 AM, <carson@taltos.org> wrote:

>
> Bash Version: 4.2
> Patch Level: 37
>
> Description:
>
> bash -c 're=".*([0-9])"; if [[ "foo1" =~ ".*([0-9])" ]]; then echo
> ${BASH_REMATCH[0]}; elif [[ "bar2" =~ $re ]]; then echo ${BASH_REMATCH[0]};
> fi'
>
> This should output foo1. It instead outputs bar2, as the first match fails.
>
>
> From bash's man page:

       [[ expression ]]
              ... ...
              An additional binary operator, =~, is available, with  the
same
              ... ...
              alphabetic characters.  Any part of the pattern may be quoted
to
              force  it  to  be  matched  as  a string.  Substrings matched
by
              ... ...


reply via email to

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