lib/rubocop/cop/mixin/regexp_metacharacter.rb in rubocop-performance-1.8.1 vs lib/rubocop/cop/mixin/regexp_metacharacter.rb in rubocop-performance-1.9.0

- old
+ new

@@ -23,34 +23,34 @@ # chars, rather than using metachars like `.` and `*` and so on? # also, is it anchored at the start of the string? # (tricky: \s, \d, and so on are metacharacters, but other characters # escaped with a slash are just literals. LITERAL_REGEX takes all # that into account.) - /\A\\A(?:#{Util::LITERAL_REGEX})+\z/.match?(regex_str) + /\A\\A(?:#{Util::LITERAL_REGEX})+\z/o.match?(regex_str) end def literal_at_start_with_caret?(regex_str) # is this regexp 'literal' in the sense of only matching literal # chars, rather than using metachars like `.` and `*` and so on? # also, is it anchored at the start of the string? # (tricky: \s, \d, and so on are metacharacters, but other characters # escaped with a slash are just literals. LITERAL_REGEX takes all # that into account.) - /\A\^(?:#{Util::LITERAL_REGEX})+\z/.match?(regex_str) + /\A\^(?:#{Util::LITERAL_REGEX})+\z/o.match?(regex_str) end def literal_at_end_with_backslash_z?(regex_str) # is this regexp 'literal' in the sense of only matching literal # chars, rather than using metachars like . and * and so on? # also, is it anchored at the end of the string? - /\A(?:#{Util::LITERAL_REGEX})+\\z\z/.match?(regex_str) + /\A(?:#{Util::LITERAL_REGEX})+\\z\z/o.match?(regex_str) end def literal_at_end_with_dollar?(regex_str) # is this regexp 'literal' in the sense of only matching literal # chars, rather than using metachars like . and * and so on? # also, is it anchored at the end of the string? - /\A(?:#{Util::LITERAL_REGEX})+\$\z/.match?(regex_str) + /\A(?:#{Util::LITERAL_REGEX})+\$\z/o.match?(regex_str) end def drop_start_metacharacter(regexp_string) if regexp_string.start_with?('\\A') regexp_string[2..-1] # drop `\A` anchor