Module: Fluent::Config

Defined in:
lib/fluent/config/regexp_type.rb

Constant Summary collapse

REGEXP_TYPE =
Proc.new { |val, opts| Config.regexp_value(val) }

Class Method Summary collapse

Class Method Details

.regexp_value(str) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/fluent/config/regexp_type.rb', line 7

def self.regexp_value(str)
  return nil unless str
  return Regexp.compile(str) unless str.start_with?("/")
  right_slash_position = str.rindex("/")
  options = str[(right_slash_position + 1)..-1]
  option = 0
  option |= Regexp::IGNORECASE if options.include?("i")
  option |= Regexp::MULTILINE if options.include?("m")
  Regexp.compile(str[1...right_slash_position], option)
end