Although just one set of operators among many, the string operators probably prove to be the ones most frequently used when expression manipulation needs to occur. Here is a summary of the more important of these operators:
Operator | Notes |
$concat | Concatenates two or more strings together. |
$trim | Removes whitespace, or other specified characters (for example, CR\LF) from both the beginning and the end of a string. This family also includes $ltrim and $rtrim, which trims only to the left or right, respectively. |
$regexMatch | New in MongoDB 4.2, returns TRUE or FALSE if the string matches the supplied regular expression. Also in this family are $regexFind, which returns the first string that matches a regular expression, and $regexFindAll, which returns all the strings that match the regex. |
$split | Splits a string based on a delimiter into an array of substrings. |
$strLenBytes | Returns the number of UTF-8-encoded bytes. Note that UTF-8-encoded characters... |