I want to match " inside a string but I am not able to add " to the list
Current my regular expression is
Regex.Replace(str, @"[\\/:*?<>|]","", RegexOptions.Compiled);
I also want to add "
\" is not accepted.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to escape
"to"".Use
""with verbatim strings..i.e
@"[\\/:*?<>|""]"OR
Just use
\"without verbatim strings.i.e
"[\\/:*?<>|\"]"A character that is preceded with forward slash
\is treated as aspecial character..For example..
\t,\n,\rare special characters..But
\eis not a special character sinceehas no special meaning..So,compiler would show you compile time errorUnrecognized escape sequenceIn order to treat characters preceded by
\literally(i.e to make it non special character) we use verbatim string i.e@""