Extension:MultiReplace

From MediaWiki.org

Jump to: navigation, search

MultiReplace enhances parser with ability to perform (multiple) regex and/or plain string replacement function(s) on any given string. Original idea by Dantman[1].

           

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
MultiReplace

Release status: beta

Implementation  Parser function
Description Enhances parser with ability to perform multiple regex and/or plain string replace function on given string
Author(s)  Matěj GrabovskýTalk
Last Version  0.1 (2009-03-17)
MediaWiki  1.6.0+
License GNU GPL 3 or newer
Download Extension:MultiReplace/Code

check usage (experimental)

Contents

[edit] Usage

This can extension is used as any other parser functions extension.

[edit] Syntax

{{ #multireplace: string | regex pattern or string to be replaced = replacement | ... }}

[edit] Example

{{#multireplace:FooBar--fobaz|/(.*)--(.*)/='''$1'''.''$2''|o=0|a=4}}

will produce:

F00B4r.f0b4z

The extension automatically recognises whether the first parameter (before =) is a regular expression or not. You can use regular wiki syntax inside of the function.

[edit] Download instructions

Copy and paste the code from this page and place it in $IP/extensions/MultiReplace/MultiReplace.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

[edit] Installation

To install this extension, add the following code to your LocalSettings.php:

# MultiReplace extension
require_once( "$IP/extensions/MultiReplace/MultiReplace.php" );

[edit] References

  1. http://www.mediawiki.org/w/index.php?title=User:Dantman/Extension_Ideas&oldid=177230

[edit] See also