If you're suspicious about quoting that regex, `[[ ]]` has special quoting rules in bash. I tested that code snippet in bash-3.2 and bash-4.2 on linux, but admittedly not on bash 3.x on OS X, someone should probably do that :)