【发布时间】:2018-03-06 23:38:16
【问题描述】:
我正在使用 Visual Studio 2017,尝试使用正则表达式进行搜索和替换以执行以下操作。我想用<li>line</li>包围我的文本文件中的每一行
例如:
This is line 1 to be surrounded with list item tags
This is line 2 to be surrounded with list item tags
This is line 3 to be surrounded with list item tags
想要的输出
<li>This is line 1 to be surrounded with list item tags</li>
<li>This is line 2 to be surrounded with list item tags</li>
<li>This is line 3 to be surrounded with list item tags</li>
我尝试了以下方法:
搜索:^.*$
替换:<li>$1</li>
结果是:
<li>$1</li>
<li>$1</li>
<li>$1</li>
我该怎么做?
【问题讨论】:
-
到目前为止你得到了什么?
-
$1 应该引用的正则表达式中的捕获组在哪里?
标签: c# regex visual-studio