On Wed, Oct 17, 2012 at 5:18 AM, <car...@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 ... ...