MediaWiki 维基文本模板的正则表达式
Yaron Koren 的 ReplaceText MediaWiki 扩展允许我使用正则表达式来替换 MediaWiki 中的文本。我有大约 300 个 MediaWiki 页面,其中有两个模板实例。我只想使用正则表达式删除第二个模板。 (替换为任何内容)
我有:
}} <--end of first template-->
{{Template Call
|blahField=blahValue
|blahField=blahValue
|...
}}
我想我想搜索: ^[ \\}} \r \\{{ *? ]
并将其替换为: ^[ \\}} ]
但是当我在 rexv.org
感谢有关正则表达式的一些帮助。
Yaron Koren's ReplaceText MediaWiki extenion allows me to use regular expressions to replace text in MediaWiki. I have about 300 MediaWiki pages that have two instances of a template. I want to delete only the second template using regular expressions. (replace it with nothing)
I have:
}} <--end of first template-->
{{Template Call
|blahField=blahValue
|blahField=blahValue
|...
}}
I think I want to search for: ^[ \\}} \r \\{{ *? ]
and replace it with: ^[ \\}} ]
but this is not producing the result I want when I test it at rexv.org
Appreciate some help with regular expressions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在扩展页面上显示
所以也许您使用的字符不起作用。是否有可能 \ 搞砸了?
On the extension page it says
So maybe the characters you are using don't work. Is it possible the \ is messing it up?
ReplaceText 不适合此类替换。使用 PyWikipediaBot 或 AutoWikiBrowser。
ReplaceText is not suitable for such replacements. Use PyWikipediaBot or AutoWikiBrowser.
我在这里有一些技巧:
{{Template Call}}
模板清空。\{\{ *Template[ _]Call
(使用正则表达式以避免格式错误的调用)替换为{{subst:Template Call
。Template Call
位置将被{{Template Call}}
的内容替换,该内容是空的。希望有帮助。
I have some hack here:
{{Template Call}}
Template to empty.\{\{ *Template[ _]Call
(with regex to avoid badly-formatted calls) to{{subst:Template Call
.Template Call
will be replace by contents of{{Template Call}}
, which is empty.Hope it helps.