Module: Fluent::Compat::StringUtil

Defined in:
lib/fluent/compat/string_util.rb

Class Method Summary collapse

Class Method Details

.match_regexp(regexp, string) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fluent/compat/string_util.rb', line 20

def match_regexp(regexp, string)
  begin
    return regexp.match(string)
  rescue ArgumentError => e
    raise e unless e.message.index("invalid byte sequence in".freeze).zero?
    $log.info "invalid byte sequence is replaced in `#{string}`"
    string = string.scrub('?')
    retry
  end
  return true
end