The regex that I use does not allow characters

regex = new Regex("(" + str1 + ")", RegexOptions.IgnoreCase);                    

I use these regular expressions to search for text ignoring case and substrings. But when I I give the characters as input, I get an exception ArgumentInvalid. How can I let this also look for characters? I use this expression in C # .Net

+3
source share
1 answer

You need to avoid regex.

Use Regex.Escape

+6
source

Source: https://habr.com/ru/post/1787617/


All Articles