0

前:

=={{int:filedesc}}==
{{Information
|description = wikiwoordenboek audio
|date =
|source =
|author =
|permission =
|other_versions =
}}
[[Category:Dutch pronunciation|Example]]

是否可以找到|and之间的任何内容]],然后用它来替换“wikiwoodenboek 音频”

后:

=={{int:filedesc}}==
{{Information
|description = Example
|date =
|source =
|author =
|permission =
|other_versions =
}}
[[Category:Dutch pronunciation|Example]]
4

2 回答 2

0

使用mwparserfromhell

>>> import mwparserfromhell
>>> t = """=={{int:filedesc}}==
... {{Information
... |description = wikiwoordenboek audio
... |date =
... |source =
... |author =
... |permission =
... |other_versions =
... }}
... [[Category:Dutch pronunciation|Example]]"""
>>> for i in mwparserfromhell.parse(t).filter_templates():
...     if 'information' in i.name.lower():
...         i.get('description').value = 'Example'
... 
>>> t
u'{{Information\n|description =Example|date =\n|source =\n|author =\n|permission =\n|other_versions =\n}}'
于 2018-01-25T21:44:41.107 回答
0

尝试这个

(\|description =\s*)([^\n]+)(.*\[\[)([^\|]+\|)([^]]+)

正则表达式演示

于 2016-04-19T00:02:25.677 回答