AWS Security ChangesHomeSearch

AWS documentdb documentation change

Service: documentdb · 2026-03-31 · Documentation low

File: documentdb/latest/developerguide/regexMatch.md

Summary

Added comprehensive documentation for the $regexMatch operator in Amazon DocumentDB, including syntax, parameters, examples in MongoDB Shell, Node.js, and Python, with connection examples showing TLS configuration

Security assessment

This change documents a new regexMatch operator feature in DocumentDB 5.0. While the code examples include TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which demonstrate security best practices for secure connections, there is no evidence this addresses a specific security vulnerability or incident. The change primarily adds feature documentation with security-conscious examples.

Diff

diff --git a/documentdb/latest/developerguide/regexMatch.md b/documentdb/latest/developerguide/regexMatch.md
index 8b1378917..1489e01fc 100644
--- a//documentdb/latest/developerguide/regexMatch.md
+++ b//documentdb/latest/developerguide/regexMatch.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#regexMatch "Open PDF")
@@ -1,0 +3,152 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $regexMatch
+
+New from version 5.0. Not supported by Elastic cluster.
+
+The `$regexMatch` operator in Amazon DocumentDB is used to perform regular expression matching on string fields. It returns a boolean value (`true` or `false`) indicating whether the input string matches the specified pattern.
+
+**Parameters**
+
+  * `input`: The string to test against the regular expression.
+
+  * `regex`: The regular expression pattern to match.
+
+  * `options`: (Optional) Flags to modify the regular expression behavior, such as case-insensitive matching (`i`) or multiline matching (`m`).
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$regexMatch` operator to check if names start with the letter 'M'. The operator returns `true` or `false` for each document.
+
+**Create sample documents**
+    
+    
+    db.users.insertMany([
+      { "_id":1, name: "María García", email: "marí[email protected]" },
+      { "_id":2, name: "Arnav Desai", email: "[email protected]" },
+      { "_id":3, name: "Martha Rivera", email: "[email protected]" },
+      { "_id":4, name: "Richard Roe", email: "[email protected]" },
+    
+    ]);
+
+**Query example**
+    
+    
+    db.users.aggregate([
+      {
+        $project: {
+          name: 1,
+          startsWithM: {
+            $regexMatch: {
+              input: "$name",
+              regex: "^M",
+              options: "i"
+            }
+          }
+        }
+      }
+    ]);
+
+**Output**
+    
+    
+    { _id: 1, name: 'María García', startsWithM: true },
+    { _id: 2, name: 'Arnav Desai', startsWithM: false },
+    { _id: 3, name: 'Martha Rivera', startsWithM: true },
+    { _id: 4, name: 'Richard Roe', startsWithM: false }
+
+## Code examples
+
+To view a code example for using the `$regexMatch` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function checkNamePattern() {
+      const client = await MongoClient.connect('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false');
+      const db = client.db('test');
+      const collection = db.collection('users');
+    
+      const result = await collection.aggregate([
+        {
+          $project: {
+            name: 1,
+            startsWithM: {
+              $regexMatch: {
+                input: "$name",
+                regex: "^M",
+                options: "i"
+              }
+            }
+          }
+        }
+      ]).toArray();
+    
+      console.log(result);
+    
+      await client.close();
+    }
+    
+    checkNamePattern();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def check_name_pattern():
+        client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
+        db = client.test
+        collection = db.users
+    
+        result = list(collection.aggregate([
+            {
+                '$project': {
+                    'name': 1,
+                    'startsWithM': {
+                        '$regexMatch': {
+                            'input': '$name',
+                            'regex': '^M',
+                            'options': 'i'
+                        }
+                    }
+                }
+            }
+        ]))
+    
+        print(result)
+    
+        client.close()
+    
+    check_name_pattern()
+
+![Warning](https://d1ge0kk1l5kms0.cloudfront.net/images/G/01/webservices/console/warning.png) **Javascript is disabled or is unavailable in your browser.**
+
+To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.
+
+[Document Conventions](/general/latest/gr/docconventions.html)
+
+$regexFindAll
+
+$replaceAll
+
+Did this page help you? - Yes
+
+Thanks for letting us know we're doing a good job!
+
+If you've got a moment, please tell us what we did right so we can do more of it.
+
+Did this page help you? - No
+
+Thanks for letting us know this page needs work. We're sorry we let you down.
+
+If you've got a moment, please tell us how we can make the documentation better.