Imagine this scenario: Users enter a keyword (e.g. hello
) in my asp.net
mvc
application and click search
. In the C#
code, I create a JavaScript
RegExp
string (/hello/i
), which is then used in a query to search MongoDB
. The query looks like this:
db.Posts.find( { "title" : /hello/i } )
This retrieves all posts with hello
in their title.
However, if the keyword contains special characters (such as \
or (
), the js regexp
may be built incorrectly.
Are there any libraries in C#
that can help parse this?