Module: Fluent::StringUtil

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

Class Method Summary collapse

Class Method Details

.match_regexp(regexp, string) ⇒ Object



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

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