Replace Text

Revision as of 10:24, 6 December 2016 by WikiSysop (talk | contribs) (1 revision: Migration)

De.png En-active.png

The ReplaceText extension from MediaWiki provides features to change text passages in articles or article titles. With a form, the existing text and the wanted text can be typed in. The extension searches for this words or text passages and replaces it automatically. For this purpose, also filters and configurations are available. In addition to this, also complex text changes can be done by using placeholders and regular expressions.  

Icon-note.png
Hint

The MediaWiki extension ReplaceText can be used with both MediaWiki and BlueSpice. The extension is available for download in our  BlueSpice Marketplace.


Where do I find ReplaceText?

To make this global changes, the extension provides a form at a special page. You can find it in the list of all special pages (Special:SpecialPages) in paragraph "Data and tools" or directly at Special:ReplaceText.

The "ReplaceText Form"

Strictly speaking, there are two forms. In the first form you can:

  • type in the already exiting, to be changed text
  • type in the wanted, new text
  • activate the checkbox for the usage of placeholders or regular expressions
  • choose the namespaches, in which the changes should take place
  • select additional filters for categories or page prefixes
  • activate replacement for text or titles


If you made all your entries and configurations in this form, you will be led to the second form by clicking on the "Continue" button. All found articles and article titles, which contain the substitutional parts, will be listed there. Uncheck the boxes of the articles, which should not be changed.


Moreover, there are two further options for configuration. Changes on the article title will be realized by moving the original page - according to the wiki principle. Due to this, there are some configurations for the moved page. Decide if: 

  • there should be a redirect from the moved page to the new one
  • this page should be added to your watchlist

Confirm your choice with the "Replace" button to trigger the automatic replacement of the text passages. The last step is a confirmation from the system, which shows you the what has been replaced and in how many articles this has been done. 

Usage of regular expressions

To use regular expressions for replacing text, the corresponding box in the first form must be checked to activate the functionality. Only a subset of the regular expressions of PHP and MySQL can be used. The following characters can be used:

( ) . * + ? [ ] |  as well as $1, $2 etc.

If the characters should be interpreted as real characters and not as part of a regular expression, a "\" must be added beforehand (like in the second example below: the dot is interpretet as a dot).

Examples:

Search String Replace String Behaviour
a(.*)c ac$1 Places all characters between a nad c at the end, e.g.:
azioc to aczio
([0-9]*)\.([0-9]*) $1,$2 Replaces the dot between the two numerical orders with a comma, e.g.:
2465.8924 zu 2465,8924

 

If you want to move a text part, which is placed between two numerical orders, you would type in the following regular expression according to the example given above:

Search String: 123(.*)456

Replace String: $1123456

to move the text from the middle to the beginning.

Due to the facht that a numerical order follows, the placeholder ($1) can not be used like meantioned above. In this case, the placeholder must be put in brackets to explicitly assign the numbering:

Replace String: {$1}123456


Automatic replacements and version history

Also automatically done changes are edits or the article content and will be stored as new versions of the article. Those versions are marked as minor edits and have an entry in the version history of the article. Also further meta information is saved there in addition to the normal data like the time stamp, the editor, etc. Further information for replacements with ReplaceText: 

  • ruther designation of the user who initiated the replacement
  • information about the process (e.g. "moved the page xy to yx without a redirect")
  • the kind of text replacement


Useful links

Attachments

Discussions