我想<br>
用 2 个换行符替换 HTML 标记的值。即我想要的是
$string=~s/br>/\n\n/s;
但不知何故它不起作用。而它适用于单个新行。即如果我这样做:
$string=~s/br>/\n/s;
它工作正常。我究竟做错了什么?
如果您正在谈论 vim 的substitute
命令,那么您可能希望\r
在替换字符串中使用而不是\n
. 在这种情况下,vim 将\n
其视为 NULL,而不是换行符。
相关片段来自:help sub-replace-special
:
<CR> split line in two at this point
(Type the <CR> as CTRL-V <Enter>) *s<CR>*
\r idem *s/\r*
\<CR> insert a carriage-return (CTRL-M)
(Type the <CR> as CTRL-V <Enter>) *s/\<CR>*
\n insert a <NL> (<NUL> in the file)