我有这个代码将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>
我有一个发出 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)
我想在发送此请求时避免任何类型的错误。
严格来说,\n告诉new line或应该是正确的用法\r\n吗?
关于这个请求格式有什么建议吗?
谢谢你的帮助。