On Tue, Oct 16, 2012 at 02:18:40PM -0700, car...@taltos.org wrote:
> if [[ "foo1" =~ ".*([0-9])" ]]; then
As others have said, you must NOT quote the regular expression on the
right-hand side of the =~ operator. If you quote it, it becomes a
plain string, overriding the =~ operator entirely.
The
Am 17.10.2012 03:13, schrieb Clark WANG:
> On Wed, Oct 17, 2012 at 5:18 AM, 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]};
>>
On Wed, Oct 17, 2012 at 5:18 AM, 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 outpu