MongoDB String Operators

MongoDB string operators are a set of special operators used to manipulate string type fields, which can be used to perform various processing and conversion operations on strings in both aggregation queries and regular queries. This page compiles the string operators in MongoDB.

  1. $concat

    The Mongodb $concat operator is used to concatenate strings. This operator can combine multiple strings into a single string.
  2. $indexOfBytes

    $indexOfBytes is a string operator in MongoDB used to find the first occurrence of a substring in a string and return its starting position.
  3. $indexOfCP

    $indexOfCP is a string operator in MongoDB used to find the starting position of a substring within a string.
  4. $ltrim

    The MongoDB $ltrim operator is used to remove specified characters from the left side of a string.
  5. $replaceAll

    The MongoDB $replaceAll operator can find and replace all matching substrings within a string.
  6. $replaceOne

    The MongoDB $replaceOne operator is used to update the first document in a collection that matches the specified condition.
  7. $rtrim

    The MongoDB $rtrim operator is used to remove specified characters from the end of a string.
  8. $split

    The MongoDB $split operator is used to split strings and extract specific substrings or split a string into an array.
  9. $strcasecmp

    The $strcasecmp operator is an aggregation operator used for string comparison in MongoDB.
  10. $strLenBytes

    $strLenBytes is an aggregation operator in MongoDB that is used to calculate the number of bytes in a string.
  11. $strLenCP

    The $strLenCP operator is an aggregation operator in MongoDB used to calculate the number of characters in a string.
  12. $substrBytes

    The $substrBytes operator is a string aggregation operator in MongoDB used to extract a substring from a string.
  13. $substrCP

    $substrCP is a string aggregation operator in MongoDB used to extract a substring from a string by code point.
  14. $toLower

    The $toLower operator is a string aggregation operator in MongoDB that converts a string to its lowercase form.
  15. $toUpper

    The Mongodb $toUpper operator is a string aggregation operator that converts a string to uppercase.
  16. $trim

    The MongoDB $trim operator is a string aggregation operator used to remove specified characters or whitespace from a string.