muthu prakash
muthu prakash

Reputation: 31

The regex I use doesn't allow symbols

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

I use this regular expressions to search the text with ignore case and substrings. But when I I give symbols as input, I am getting a ArgumentInvalid exception. How can I allow this to search for symbols also? I am using this expression in C#.Net

Upvotes: 3

Views: 133

Answers (1)

leppie
leppie

Reputation: 117250

You need to escape the regex.

Use Regex.Escape

Upvotes: 6

Related Questions