diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb
index <HASH>..<HASH> 100644
--- a/railties/lib/rails/backtrace_cleaner.rb
+++ b/railties/lib/rails/backtrace_cleaner.rb
@@ -16,7 +16,7 @@ module Rails
       add_filter { |line| line.sub(DOT_SLASH, SLASH) } # for tests
 
       add_gem_filters
-      add_silencer { |line| line !~ APP_DIRS_PATTERN }
+      add_silencer { |line| !APP_DIRS_PATTERN.match?(line) }
     end
 
     private
Update backtrace cleaner to use `Regexp#match?`