When an user inputs a string that only contains one parenthesis, the Regex.IsMatch()
breaks. Inputting a single [
also breaks the program.
Regex.IsMatch("John Cena", "Test(", RegexOptions.IgnoreCase)
In this case John Cena
is the name from my database. The user then inputs Test(
in the search input, but the server will return an 500 error, because Regex.IsMatch()
breaks because of the input.
How do I escape all of these, so I can actually test one input to the one I have in my database? I simply want to test if the user's input matches the entry from the database. And yes, the name from the database can contain a parenthesis, so it would be nice if John Cena(
would match the user's input, if he types John Cena(
.