Nearby lessons
16 of 22🧵 MongoDB: String Operators
MongoDB provides powerful string operators for text manipulation, conversion, formatting, and pattern matching.
These operators are mainly used within the aggregation pipeline to transform or analyze text data efficiently.
📚 Initial Data Setup — students Collection
Example01
📘 Additional Data Setup — students2 Collection
Example02
📗 Date Setup — students3 Collection
Example03
1️⃣ $toString — Convert Age to String
Example04
2️⃣ $toUpper — Convert to Uppercase
Example05
3️⃣ $toLower — Convert to Lowercase
Example06
4️⃣ $strLenBytes — Byte Length of String
Example07
5️⃣ $strLenCP — Code Point Length
Example08
6️⃣ $strcasecmp — Case-Insensitive Comparison
Example09
7️⃣ $substr — Deprecated Substring
Example10
8️⃣ $substrBytes — Byte-Based Substring
Example11
9️⃣ $substrCP — Code Point Substring
Example12
🔟 $replaceOne — Replace First Match
Example13
1️⃣1️⃣ $replaceAll — Replace All Matches
Example14
1️⃣2️⃣ $concat — Combine Strings
Example15
1️⃣3️⃣ $split — Split String into Array
Example16
1️⃣4️⃣ $ltrim — Left Trim
Example17
1️⃣5️⃣ $rtrim — Right Trim
Example18
1️⃣6️⃣ $trim — Trim Both Sides
Example19
1️⃣7️⃣ $dateFromString — Convert String to Date
Example20
1️⃣8️⃣ $dateToString — Convert Date to String
Example21
1️⃣9️⃣ $indexOfBytes — Find Byte Position
Example22
2️⃣0️⃣ $indexOfCP — Find Code Point Position
Example23
2️⃣1️⃣ $regexFind — Find First Regex Match
Example24
2️⃣2️⃣ $regexFindAll — Find All Regex Matches
Example25
2️⃣3️⃣ $regexMatch — Regex Test
Example26