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 best approach is to place the RE into a shell variable: re=".*([0-9])" if [[ foo1 =~ $re ]]; then This avoids many issues, including changes in bash's behavior in the 3.x versions.