diff --git a/lib/rubocop/cop/style/regexp_literal.rb b/lib/rubocop/cop/style/regexp_literal.rb
index <HASH>..<HASH> 100644
--- a/lib/rubocop/cop/style/regexp_literal.rb
+++ b/lib/rubocop/cop/style/regexp_literal.rb
@@ -170,27 +170,31 @@ module RuboCop
         end
 
         def correct_inner_slashes(node, corrector)
-          search_indices(
-            node_body(node),
-            inner_slash_before_correction(node)
-          ).each do |index|
+          regexp_begin = node.loc.begin.end_pos
+
+          inner_slash_indices(node).each do |index|
+            start = regexp_begin + index
+
             corrector.replace(
               range_between(
-                node.loc.begin.end_pos + index,
-                node.loc.begin.end_pos + index +
-                  inner_slash_before_correction(node).length
+                start,
+                start + inner_slash_before_correction(node).length
               ),
               inner_slash_after_correction(node)
             )
           end
         end
 
-        def search_indices(text, pattern)
-          index = -1
+        def inner_slash_indices(node)
+          text    = node_body(node)
+          pattern = inner_slash_before_correction(node)
+          index   = -1
           indices = []
+
           while (index = text.index(pattern, index + 1))
             indices << index
           end
+
           indices
         end
Refactor complex method in Style/RegexpLiteral cop

This cop had a relatively complex (ABC = <I>) method `#correct_inner_slashes`.
This change attempts to simplify it by making the method `#search_indices`
less general, and having it take on some of the responsibility that was
previously in `#correct_inner_slashes`.