0

I need to change:

","
":"
"{"
"}"

From string to ""

I wrote this:

Regex remove = new Regex("\"\"\":\"\"{\"\"}\"]");
remove.Replace(str, "");

But this didn't change the values I needed to change. Where did I make a error?

4

1 回答 1

4

The replace method returns the replaced string.

You should try

Regex remove = new Regex(",|:|\\{|\\}");
str = remove.Replace(str, "");

Note: The regex looks for , : { and } within "".

EDIT: Modified Code with regular expressing string as well, thanks to ArsenMkrt

于 2012-12-05T13:58:54.143 回答