小编788*_*498的帖子

c#regex在[pre = html]代码[br /]代码[/ pre]之间替换<br />或[br /]到"\n"

我有这个代码将BBCode替换为html,当我想要替换标签<br />[br /]其中的问题时会出现问题[pre=html] code [/pre].

Regex exp; string str;

 str = "more text [pre=html] code code code code [br /] code code code [br /] code code [/pre] more text";

 str = str.Replace("[br /]","<br />");

 exp = new Regex(@"\[b\](.+?)\[/b\]");
 exp.Replace str = (str,"<strong>$1</strong>");
 ......
 exp = new Regex (@ "\[pre\=([a-z\]]+)\]([\d\D\n^]+?)\[/pre\]");
 str = exp.Replace(str, "<pre class=\"$1\">" + "$2" + "</pre>");
Run Code Online (Sandbox Code Playgroud)

正如您要更改<br />[br /]使用"\n"内部[pre=html] code [/pre]<pre class=html> code </pre>

c# regex asp.net-mvc replace

3
推荐指数
1
解决办法
8000
查看次数

HTTP/1.1 标头的新行定义

我有一个发出 HTTP POST 请求的嵌入式系统,但是我知道标头必须具有格式。

在这种情况下,我有这个要求:

POST / HTTP/1.1\n
Host: 192.168.1.15\n
Connection: close\n
Content-Length: 44\n
Content-Type: application/json\n
\n
{\n
"command": "snapPicture",\n
"selfTimer": 0\n
}
Run Code Online (Sandbox Code Playgroud)

我想在发送此请求时避免任何类型的错误。

  1. 严格来说,\n告诉new line或应该是正确的用法\r\n吗?

  2. 关于这个请求格式有什么建议吗?

谢谢你的帮助。

httprequest http-1.1 http-headers

3
推荐指数
1
解决办法
8102
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

http-1.1 ×1

http-headers ×1

httprequest ×1

regex ×1

replace ×1