我有数百个要编码的列表项。每个列表项包含2行中的标题和描述。所以我需要做的是用标签包裹2行。有没有办法使用sublime text 2?我正在使用Windows操作系统。
这是所需的输出:
<ul>
<li>
this is the title
this is the descrpition
</li>
<li>
this is the title
this is the descrpition
</li>
</ul>
原始文本如下所示:
这是标题
这是描述
这是标题
这是描述
=====
我尝试过使用ctrl + shift + G并使用ul&gt; li *但不幸的是它用<li>
如果可以使用sublime文本,我实际上需要这种类型的结构:
<ul>
<li>
<span class="title">this is the title</span>
<span class="description">this is the descrpition</span>
</li>
<li>
<span class="title">this is the title</span>
<span class="description">this is the descrpition</span>
</li>
</ul>
答案 0 :(得分:0)
使用查找和替换的两步过程怎么样?
我假设:
<ul>
处理包裹并自行缩进。 this is title
this is description
this is title
this is description
确保已启用正则表达式匹配使用这些值执行查找和替换。
找到什么:: ((.*\n){1,2})
REPLACE WITH :: <li>\n\1</li>\n
结果:
<li>
this is title
this is description
</li>
<li>
this is title
this is description
</li>
确保已启用正则表达式匹配使用这些值执行查找和替换。
找到什么:: (<li>\n)(.*)\n(.*)
REPLACE WITH :: \1 <span class="title">\2</span>\n <span class="description">\3</span>
结果:
<li>
<span class="title">this is title</span>
<span class="description">this is description</span>
</li>
<li>
<span class="title">this is title</span>
<span class="description">this is description</span>
</li>
您怎么看?
足够接近有用吗?