Search code examples
regexpywikibot

Can regex do this?


Before:

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

Is it possible to find whatever is between | and ]], and then use it to replace "wikiwoordenboek audio"

After:

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

Solution

  • Try this

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

    Regex demo