Class: MemDB::RegexpEngines::Re2

Inherits:
Object
  • Object
show all
Defined in:
lib/mem_db/regexp_engines/re2.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, ignore_case: false) ⇒ Re2

Returns a new instance of Re2.



12
13
14
15
16
17
18
19
20
# File 'lib/mem_db/regexp_engines/re2.rb', line 12

def initialize(source, ignore_case: false)
  opts = {
    one_line: false
  }
  opts[:case_sensitive] = false if ignore_case
  multiline_source = "(?s:#{source})"

  @rx = ::RE2::Regexp.new(multiline_source, **opts)
end

Class Method Details

.quote(str) ⇒ Object



8
9
10
# File 'lib/mem_db/regexp_engines/re2.rb', line 8

def self.quote(str)
  ::RE2::Regexp.quote(str)
end

Instance Method Details

#match?(str) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/mem_db/regexp_engines/re2.rb', line 22

def match?(str)
  @rx.match?(str)
end