$regexFindAll

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

Reference group: String aggregation expressions

What it does

Returns details for all regex matches.

Syntax

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

Use case

Extract repeated tokens.

$regexFindAll: practical example
{ $project: { matches: { $regexFindAll: { input: "$text", regex: "[A-Z]+" } } } }
💡 Explanation Returns details for all regex matches. When to use it Extract repeated tokens.
Key Takeaways
  • Returns details for all regex matches.
  • Typical use: Extract repeated tokens.