module Jekyll::Algolia::Utils

def self.match?(string, regex)

needed for older versions.
Newer versions of Ruby have easy ways to test this, but a wrapper is

regex - The regex to match against
string - The string to test

Public: Check if a string matches a regex
def self.match?(string, regex)
  # Ruby 2.4 introduces .match?
  return regex.match?(string) if regex.respond_to?(:match?)
  # Older versions of Ruby have to deal with =~ returning nil if no match
  # is found
  !(string =~ regex).nil?
end