diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index a4ed78a7803a3261dbd8a51f24f617c7c89b7dec..e2367a0c11b63651268a6de83182ceb059e26e24 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -166,10 +166,12 @@ module SharedEnvExtension
   # end</pre>
   def compiler
     @compiler ||= if (cc = @cc)
-      warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP
+      warn_about_non_apple_gcc(cc) if cc.match?(GNU_GCC_REGEXP)
+
       fetch_compiler(cc, "--cc")
     elsif (cc = homebrew_cc)
-      warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP
+      warn_about_non_apple_gcc(cc) if cc.match?(GNU_GCC_REGEXP)
+
       compiler = fetch_compiler(cc, "HOMEBREW_CC")
 
       if @formula
diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb
index 70e76567373951b6a5faf458cfc960062f3da1d8..8afbc139742ff6878da71c79b9b9dabe64928e80 100644
--- a/Library/Homebrew/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/ENV/std.rb
@@ -46,9 +46,9 @@ module Stdenv
 
     send(compiler)
 
-    return unless cc =~ GNU_GCC_REGEXP
+    return unless cc.match?(GNU_GCC_REGEXP)
 
-    gcc_formula = gcc_version_formula($&)
+    gcc_formula = gcc_version_formula(cc)
     append_path "PATH", gcc_formula.opt_bin.to_s
   end
   alias generic_setup_build_environment setup_build_environment
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb
index ba3015a62fabd302b998a7c77bd0f1080db6752c..4bbe7e054be10ba9ef9a3f3f197ca84327518da0 100644
--- a/Library/Homebrew/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/ENV/super.rb
@@ -111,7 +111,7 @@ module Superenv
     path.append("/usr/bin", "/bin", "/usr/sbin", "/sbin")
 
     begin
-      path.append(gcc_version_formula($&).opt_bin) if homebrew_cc =~ GNU_GCC_REGEXP
+      path.append(gcc_version_formula(homebrew_cc).opt_bin) if homebrew_cc.match?(GNU_GCC_REGEXP)
     rescue FormulaUnavailableError
       # Don't fail and don't add these formulae to the path if they don't exist.
       nil