$regexFind

Reference type:Cheat sheetFormat:Syntax + example + use case

Reference group: String aggregation expressions

What it does

Returns details of the first regex match and captures.

Syntax

{$regexFind: { input, regex, options? }}

Use case

Extract pattern matches.

$regexFind: practical example
{ $project: { found: { $regexFind: { input: "$email", regex: "^[^@]+@[^@]+$" } } } }
💡 Explanation Returns details of the first regex match and captures. When to use it Extract pattern matches.
Key Takeaways
  • Returns details of the first regex match and captures.
  • Typical use: Extract pattern matches.