Module: RE2::String
- Defined in:
- lib/re2/string.rb
Instance Method Summary collapse
-
#re2_escape ⇒ String
(also: #re2_quote)
Escapes all potentially meaningful regexp characters.
-
#re2_gsub(*args) ⇒ Object
Replaces every occurrence of
patternwithrewriteand return a new string. -
#re2_match(pattern, *args) ⇒ Boolean, RE2::MatchData
Match the pattern and return either a boolean (if no submatches are required) or a MatchData instance.
-
#re2_sub(*args) ⇒ Object
Replaces the first occurrence
patternwithrewriteand returns a new string.
Instance Method Details
#re2_escape ⇒ String Also known as: re2_quote
Escapes all potentially meaningful regexp characters. The returned string, used as a regular expression, will exactly match the original string.
95 96 97 |
# File 'lib/re2/string.rb', line 95 def re2_escape RE2.QuoteMeta(self) end |
#re2_gsub(*args) ⇒ Object
Replaces every occurrence of pattern with rewrite and return a new string.
39 40 41 |
# File 'lib/re2/string.rb', line 39 def re2_gsub(*args) RE2.GlobalReplace(self, *args) end |
#match(pattern) ⇒ RE2::MatchData #match(pattern, 0) ⇒ Boolean #match(pattern, number_of_matches) ⇒ RE2::MatchData
Match the pattern and return either a boolean (if no submatches are required) or a MatchData instance.
84 85 86 |
# File 'lib/re2/string.rb', line 84 def re2_match(pattern, *args) RE2::Regexp.new(pattern).match(self, *args) end |
#re2_sub(*args) ⇒ Object
Replaces the first occurrence pattern with rewrite and returns a new string.
24 25 26 |
# File 'lib/re2/string.rb', line 24 def re2_sub(*args) RE2.Replace(self, *args) end |