       else
         re = RegExp substring, "m" # multiline matching
       if objectValueStr
-        match = objectValueStr.match re
+        match = re.test objectValueStr
 
       # if substring in object value str
       return true if match

  objectValue = object[objectKey]
  objectValue = JSON.stringify(objectValue) # match in stringified arrays and objects too
  re = RegExp testValue, "im"
  match = objectValue.match re
  return if match then true else false

# "And" the results of multiple tests
andTest = (object, tests) ->

# Extract specific time from the document pubdate field and compare it with the test
matchesPubdate = (objectKey, pubdateTest, object) ->
  objectValue = object[objectKey]
  year = new Date(objectValue).getFullYear() # convert to milliseconds

  if 'year' of pubdateTest # compare years
    testValue = pubdateTest['year']
