| 1 | # frozen_string_literal: true |
| 2 | |
| 3 | # re2 (https://github.com/mudge/re2) |
| 4 | # Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to |
| 5 | # backtracking regular expression engines like those used in PCRE, Perl, and |
| 6 | # Python". |
| 7 | # |
| 8 | # Copyright (c) 2010, Paul Mucur (https://mudge.name) |
| 9 | # Released under the BSD Licence, please see LICENSE.txt |
| 10 | |
| 11 | require "re2" |
| 12 | |
| 13 | module RE2 |
| 14 | # @deprecated Use methods on {RE2} and {RE2::Regexp} instead. |
| 15 | module String |
| 16 | # @deprecated Use {RE2.replace} instead. |
| 17 | def re2_sub(*args) |
| 18 | RE2.replace(self, *args) |
| 19 | end |
| 20 | |
| 21 | # @deprecated Use {RE2.global_replace} instead. |
| 22 | def re2_gsub(*args) |
| 23 | RE2.global_replace(self, *args) |
| 24 | end |
| 25 | |
| 26 | # @deprecated Use {RE2::Regexp#match} instead. |
| 27 | def re2_match(pattern, *args) |
| 28 | RE2::Regexp.new(pattern).match(self, *args) |
| 29 | end |
| 30 | |
| 31 | # @deprecated Use {RE2.escape} instead. |
| 32 | def re2_escape |
| 33 | RE2.escape(self) |
| 34 | end |
| 35 | |
| 36 | alias_method :re2_quote, :re2_escape |
| 37 | end |
| 38 | end |