匹配特定标签之间的字符串并转换为Wikilinks

问题描述 投票:0回答:1

此问题类似于我在这里问的另一个问题:Match strings between delimiting characters,但我无法修改以执行新任务。 (解决方案应与EmEditor或Notepad ++一起使用)

我需要在特定标签之间匹配文本,即<b class="b2">I have a lot of text, more text, some more text, text</b>,然后

  1. 打开标签后将第一个字符转换为小写(字母“ I”除外)
  2. 将逗号之间的内容转换为Wikilink(并消除标记)。

我已经尝试运行多个正则表达式来通过多个步骤来接近它,例如

(<b class="b2">)(.)
[[\L\2

</b>
]]

(\[\[)(\w+), (\w+)(\]\])
\1\2]], [[\3\4

输入文字:

Any text <b class="b2">I make laugh</b>: Ar. and P. γέλωτα. Some more text <b class="b2">Delight</b>: P. and V. [[τέρπω]].
Any text <b class="b2">I amuse oneself, pass the time</b>: P. διάγειν.
Any text <b class="b2">It amuses oneself with, pass the time over, amuse</b>: Ar. and P.

预期输出:

Any text [[I make laugh]]: Ar. and P. γέλωτα. Some more text [[delight]]: P. and V. [[τέρπω]].
Any text [[I amuse oneself]], [[pass the time]]: P. διάγειν.
Any text [[it amuses oneself with]], [[pass the time over]], [[amuse]]: Ar. and P.
regex notepad++ pcre emeditor
1个回答
0
投票

您应该分几个步骤进行。


替换

<b class="b2">([^<]*)</b>

[[\1]]

替换

,

]], [[

替换

[[I(\s)

[[i\1
© www.soinside.com 2019 - 2024. All rights reserved.