Let us say we have Articles collection type that have title field as string
When I make a get request /articles?title_contains=(
I will get this error : error MongoError: Regular expression is invalid: missing )
And I found out that it is because contains parameter support Regex
So the Question is how I can disable it, or make a work around
As I want to be able to search for titles with special characters
I found the solution, I just created a escape function for Regex characters :
function escapeRegex(string) {
return string.replace(/[-/\^$*+?.()|[]{}]/g, ‘\$&’);
}
and applied it on the string that comes after contains=
so all Regex characters will be escaped so it will be treated like normal string