• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2115
  • Last Modified:

Removing special characters with Regular Expression in C#.NET

Hi,
I would like to replace the following characters in an input string:
"$'&+,/:;=?@<>#%{}|\^~][`

I'm using ASP.NET and C#
I'm looking for code that looks something like this:

string specials = "\"'$&+,/:;=?@<>#%{}|\\^~][`";
Regex regex = new Regex(specials);
string output = regex.Replace("input with specials", "x");

Above code compiles but doesn't work.
Any help is appreciated.

Thanks

z
0
tyconz_helpdesk2008
Asked:
tyconz_helpdesk2008
1 Solution
 
ozoCommented:
string specials = "[\"'$&+,/:;=?@<>#%{}|\\\\^~\\]\\[`]";
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now