<< Click to Display Table of Contents >> Text |
Functions |
Syntax |
Instructions |
Examples |
---|---|---|---|
concat |
{ $concat: [ <expression1>, <expression2>, ... ] } |
Concatenates strings and returns the concatenated string. |
For example: { $concat: [ "A", " - ", "B" ] } |
ltrim |
{ $ltrim: { input: <string>, chars: <string> } } |
Removes whitespace characters, including null, or the specified characters from the beginning of a string. |
For example: { $ltrim: { input: " test " } } |
regexFind |
{ $regexFind: { input: <expression> , regex: <expression>, options: <expression> } } |
Provides regular expression (regex) pattern matching capability in aggregation expressions. If a match is found, returns a document that contains information on the first match. If a match is not found, returns null. |
For example: { $regexFind: { input: "$col", regex: /te/ } } |
regexFindAll |
{ $regexFindAll: { input: <expression> , regex: <expression>, options: <expression> } } |
Provides regular expression (regex) pattern matching capability in aggregation expressions. The operator returns an array of documents that contains information on each match. If a match is not found, returns an empty array. |
For example: { $regexFindAll: { input: "$col", regex: /te/ } } |
regexMatch |
{ $regexMatch: { input: <expression> , regex: <expression>, options: <expression> } } |
Performs a regular expression (regex) pattern matching and returns:true if a match exists,false if a match doesn’t exist. |
For example: { $regexMatch: { input: "$col", regex: /te/ } } |
rtrim |
{ $rtrim: { input: <string>, chars: <string> } } |
Removes whitespace characters, including null, or the specified characters from the end of a string. |
For example: { $rtrim: { input: " test "} } |
split |
{ $split: [ <string expression>, <delimiter> ] } |
Divides a string into an array of substrings based on a delimiter. $split removes the delimiter and returns the resulting substrings as elements of an array. If the delimiter is not found in the string, $split returns the original string as the only element of an array. |
For example: { $split: [ "June-15-2013", "-" ] } |
strcasecmp |
{ $strcasecmp: [ <expression1>, <expression2> ] } |
Performs case-insensitive comparison of two strings. Returns:1 if first string is "greater than" the second string,0 if the two strings are equal,-1 if the first string is "less than" the second string. |
For example: { $strcasecmp: [ "$col", "test" ] } |
strLenBytes |
{ $strLenBytes: <string expression> } |
Returns the number of UTF-8 encoded bytes in the specified string. |
For example: { $strLenBytes: "abcde" } |
strLenCP |
{ $strLenCP: <string expression> } |
Returns the number of UTF-8 values in the specified string. |
For example: { $strLenCP: "abcde" } |
substr |
{ $substr: [ <string>, <start>, <length> ] } |
Returns a substring of a string, starting at a specified index position and including the specified number of characters. The index is zero-based. |
For example: { $substr: [ "test", 0, 2 ] } |
substrBytes |
{ $substrBytes: [ <string expression>, <byte index>, <byte count> ] } |
Returns the substring of a string. The substring starts with the character at the specified UTF-8 byte index (zero-based) in the string and continues for the number of bytes specified. |
For example: { $substrBytes: [ "abcde", 1, 2 ] } |
substrCP |
{ $substrCP: [ <string expression>, <code point index>, <code point count> ] } |
Returns the substring of a string. The substring starts with the character at the specified UTF-8 code point (CP) index (zero-based) in the string for the number of code points specified. |
For example: { $substrCP: [ "abcde", 1, 2 ] } |
toLower |
{ $toLower: <expression> } |
Converts a string to lowercase, returning the result. |
For example: { $toLower: "TEST" } |
toUpper |
{ $toUpper: <expression> } |
Converts a string to uppercase, returning the result. |
For example: { $toUpper: "test" } |
trim |
{ $trim: { input: <string>, chars: <string> } } |
Removes whitespace characters, including null, or the specified characters from the beginning and end of a string. |
For example: { $trim: { input: " test " } } |
type |
{ $type: <expression> } |
Returns a string that specifies the BSON type of the argument. |
For example: { $type: "a" } |