【问题标题】:Notepad++ help: Adding attribute after nodeNotepad++ 帮助:在节点之后添加属性
【发布时间】:2021-06-25 06:44:20
【问题描述】:
<canvas name="A" width="11" height="11">
</canvas>
<canvas name="B" width="22" height="22">
</canvas>
<canvas name="A" width="33" height="33">
</canvas>
<canvas name="B" width="44" height="44">
</canvas>

如果之前有人问过这个问题,我们深表歉意。我想在&lt;canvas name="B" ... &lt;/canvas&gt; 节点之后添加一行&lt;additionalattribute&gt;。那可能吗?假设每个&lt;canvas name="B" 节点在标签内都有不同的值。

所以理想的结果是:

<canvas name="A" width="11" height="11">
</canvas>
<canvas name="B" width="22" height="22">
</canvas>
<additionalattribute>
<canvas name="A" width="33" height="33">
</canvas>
<canvas name="B" width="44" height="44">
</canvas>
<additionalattribute>

【问题讨论】:

    标签: notepad++


    【解决方案1】:
    • Ctrl+H
    • 查找内容:&lt;canvas name="B"[\s\S]+?&lt;/canvas&gt;\K
    • 替换为:\n&lt;additionalattribute&gt;
    • 检查 环绕
    • CHECK 正则表达式
    • 全部替换

    说明:

    <canvas name="B"        # literally
    [\s\S]+?                # 1 or more any character including newline, not greedy
    </canvas>               # literally
    \K                      # forget all we have seen until this position
    

    替换:

    \n                      # linefeed, you can use \r\n for windows EOL
    <additionalattribute>   # the tag to add
    

    屏幕截图(之前):

    截图(之后):

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多