Skip to content

$regex

Returns a RegExp object.

Options

  • string (optional) The regular expression string. Default '.*'.
  • flags (optional) Flags for the RegExp object. Default ''.

Example

{
    "expr": {
        "$regex": {
            "string": "^ab+c$",
            "flags": "i"
        }
    }   
 }
{
    "expr": {
        "$regularExpression": "^ab+c$",
        "$options": "i"
    }
}