The query team has discussed and decided on the following syntax and semantics
It takes in three expressions that must evaluate to strings: an original string, a string to search for, and a string to insert. This evaluates to a new string with the first occurrence of `find` in `input` replaced by `replacement`. If no occurrences are found, it evaluates to the input string. Expressions in each argument are first evaluated and an error thrown if any input evaluates to a non-nullish non-string type.. Next, if any arguments are nullish, returns null.
Because this is a searching algorithm and not a direct string comparison, this computation will not consider the operation's collation. This is consistent with other similar expressions like $indexOfCP and $regexFind. This expression is not required to throw an error on invalid UTF-8, though it must be implemented in such a way as to avoid undefined or unsafe behaviors when given invalid UTF-8 as input. This permits implementation of the expression as a byte-matching algorithm rather than a code point matching algorithm. This expression will not do unicode normalization. This means that a character like 'é' may not be considered a match if the input string represents it as one unicode character and the 'find' string represents it as two characters: a normal 'e' and a combining diacritical mark.
There is no method for string replacement in mongoDB(similar to "REPLACE" in Oracle or other DB)
We need this functionality in our production environment.
Kindly do the needful to add the function in your library.