I am working with MongoDB and I am searching the documents with regex expression as below.
new BsonDocument("$regex", "^(?i)" + PropertyValue + "$")
If we exactly know where the special character comes we can add '\' before it. But this value is dynamic here.
One way I can see is I can replace all these special characters with appending '\' before the special characters. But I need to look at what are the special characters on the web and also check if there is any special cases this will fail.
Is there any elegant way of doing this using regex expression.