If you want to match a regular expression while ignoring the case, shopt is the easiest method is to use.
Shopt toggles the values of variables controlling optional shell behavior. It is a bash built-in command.

#!/bin/bash
var=TeSTvaRiABlE
shopt -s nocasematch
if [[ "$var" =~ TESTVARIABLE ]]; then
echo "my regex is crazy go nuts"
else
echo "fail"
fi
my regex is crazy go nuts
You can use shopt set, unset, and print out settable options such as the ability to expand aliases and debugging options.
Another use you might find for shopt is checking to see if you’re in a restricted shell and whether or not you were called from a login shell.
Posted by admica @ 8 November 2010