-1

我有一个像下面这样的字符串作为响应。我希望这个字符串格式化,以便每个参数一个接一个地出现。就像我得到这个字符串

string  str1 = @"testmode=0<br>MessageReceived=Your order dispached and will be delived<br>Messagecount1
<br>could not access file: Error=Not enough credit send.";

我想格式化它,使它看起来像

testmode=0
message received=Your order dispached and will be delivered
message count=1
could not access file:
error=not enough credit send.
4

4 回答 4

3

尝试类似的东西

string formatted = str1.Replace("<br>",Environment.NewLine);

这只会<br>用换行符替换标签。

于 2013-07-11T11:03:38.180 回答
2

尝试

MessageBox.Show(str1.Replace(@"<br>", Environment.NewLine));

我不确定在could not access file:
你怎么知道你必须在那里换行之后换行?

于 2013-07-11T11:05:29.350 回答
2

Maybe try this using Replace to change br into newline. Put after your code this line:

str1.Replace("<br>", "\n");
于 2013-07-11T11:08:43.130 回答
1

不是最好的,但怎么样:

MessageBox.Show(string.Join(Environment.NewLine, str1.Split(new string[]{"<br>", ":"}, StringSplitOptions.None)));
于 2013-07-11T11:04:56.527 回答