MassEditRegex
MassEditRegex
This extension allows administrators to replace specific texts simultaneously in a larger number of pages. Adding texts like category assignments are also possible. The pagenames need to be specified which means a text search normally precedes the use of the extension. However, apart from providing a list of the pages to be edited other options like specifying the begining of the pagenames or categories are also possible. For categories all pages within a category are searched and edited. The extension is, for example, useful to change SemanticMW assignments, where lists of pages can be generated with the ask function.
Here are a few notes for administrators who are not familiar with this extension:
- Go to Special:MassEditRegex
- Enter a list of pagenames into the box "Pages to be edited", placing each pagename into a new line
- Enter the search text using the preg_replace format. That means the search text needs to be enclosed in forward slashes and several signs need to be escaped, like [, /, (, ), or |. The use of regular expressions is also possible.
- If the search text is not found in one of the pages listed no changes are done on that page.
- Normally it is advisable to use the "Show preview" option first. However, the preview is limited to the first 10 pages listed.
- Several search and replace expressions can be used simultaneously. For this each search and replace expression is entered in a new line, even if the replace line is blank.
- Only one change is made per line and if the search text occurs several time in a line only the last occurrence is changed.
- Search expressions in brackets (without escapes) can be referred to as $1, $1, etc. in the replace text.
- A Gateway error might occur if too many pages are changed at once (e.g. more than 200).
Example:
Search text - /(\|Publication authors=.*)A. Johnson/ Replace text - $1[[A. Johnson]]
This example places "A. Johnson" into double square brackets in all lines where "|Publication authors=" is found. The regular expression ".*" stands for any string, even for an empty string. Thus:
|Publication authors=John F. Smith and A. Johnson becomes |Publication authors=John F. Smith and [[A. Johnson]] or |Publication authors=A. Johnson and S. Wang becomes |Publication authors=[[A. Johnson]] and S. Wang