我有一个sublime文本的HTML文件,我想在每个第3个</tr>
标记之后添加换行符,将它们分组为3个
(这只需要取悦我的眼球,不会在任何网页的任何地方显示
我怎么能用正则表达式做到这一点?
我可以使用(</tr>
)轻松获得所有标签,但我希望每个第3个标签只能替换为$ 1 \ n
一些示例数据
<tr data-id="17622538">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28807">1d</th>
<td>Order 4990792 for symbol NASDAQ:OCUL has been executed at price 7.08 for 2000 shares</td>
</tr>
<tr data-id="17622537">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28808">1d</th>
<td>Order 4990792 successfully placed</td>
</tr>
<tr data-id="17622536">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28809">1d</th>
<td>Call to place market order to buy 2000 shares of symbol NASDAQ:OCUL </td>
</tr>
<tr data-id="17622538">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28807">1d</th>
<td>Order 4990792 for symbol NASDAQ:OCUL has been executed at price 7.08 for 2000 shares</td>
</tr>
<tr data-id="17622537">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28808">1d</th>
<td>Order 4990792 successfully placed</td>
</tr>
<tr data-id="17622536">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28809">1d</th>
<td>Call to place market order to buy 2000 shares of symbol NASDAQ:OCUL </td>
</tr>
<tr data-id="17622538">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28807">1d</th>
<td>Order 4990792 for symbol NASDAQ:OCUL has been executed at price 7.08 for 2000 shares</td>
</tr>
<tr data-id="17622537">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28808">1d</th>
<td>Order 4990792 successfully placed</td>
</tr>
<tr data-id="17622536">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28809">1d</th>
<td>Call to place market order to buy 2000 shares of symbol NASDAQ:OCUL </td>
</tr>
所需的输出看起来像
<tr data-id="17622538">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28807">1d</th>
<td>Order 4990792 for symbol NASDAQ:OCUL has been executed at price 7.08 for 2000 shares</td>
</tr>
<tr data-id="17622537">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28808">1d</th>
<td>Order 4990792 successfully placed</td>
</tr>
<tr data-id="17622536">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28809">1d</th>
<td>Call to place market order to buy 2000 shares of symbol NASDAQ:OCUL </td>
</tr>
<tr data-id="17622538">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28807">1d</th>
<td>Order 4990792 for symbol NASDAQ:OCUL has been executed at price 7.08 for 2000 shares</td>
</tr>
<tr data-id="17622537">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28808">1d</th>
<td>Order 4990792 successfully placed</td>
</tr>
<tr data-id="17622536">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28809">1d</th>
<td>Call to place market order to buy 2000 shares of symbol NASDAQ:OCUL </td>
</tr>
<tr data-id="17622538">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28807">1d</th>
<td>Order 4990792 for symbol NASDAQ:OCUL has been executed at price 7.08 for 2000 shares</td>
</tr>
<tr data-id="17622537">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28808">1d</th>
<td>Order 4990792 successfully placed</td>
</tr>
<tr data-id="17622536">
<th title="10/14/2016, 7:37:13 AM" data-ago-date-timer="28809">1d</th>
<td>Call to place market order to buy 2000 shares of symbol NASDAQ:OCUL </td>
</tr>
答案 0 :(得分:3)
替换:
((<tr[^<]+<th[^<]+<\/th>\s+<td[^<]+</td>\s+</tr>\s*){3})
with:
\1\n
答案 1 :(得分:1)
((\n.*?)+</tr>){3}
然后全部查找,按右箭头键,你就在那里