From mediawiki.org
Jump to navigation Jump to search
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced.svg
リリースの状態: 安定
実装 パーサー関数
説明 Allows for multiple patterns of text, either plain or RegExp based to be replaced using a parser function.
作者 Daniel Friesen (Dantmanトーク)
最新バージョン 1.3 (2012-11-04)
データベースの変更 いいえ
ライセンス GPL2 以降
  • $egReplaceSetPregLimit
  • $egReplaceSetCallLimit
translatewiki.net で翻訳を利用できる場合は、ReplaceSet 拡張機能の翻訳にご協力ください

使用状況とバージョン マトリクスを確認してください。

The ReplaceSet extension allows for patterns of text, either plain or RegExp based to be replaced. The idea is to allow many patterns to be replaced simply without overloading the Parser with dozens of ParserFunctions and allow for simple replace based syntaxes to be built such as linking certain words in a Card lore.

ReplaceSet is coded to make full use of pcre's performance. All the replacement patterns are passed together at once to pcre instead of looping over each one and doing replacements separate, this avoids shuffling between pcre and php.


{{#replaceset: text to replace | regex pattern or string to be replaced = replacement | ... }}

Regex patterns are wrapped in !pattern! #pattern# (pattern) [pattern] or {pattern}, and may be followed with any of the flags "imsxADU" (see php's documentation on pcre modifiers for what they individually do). Patterns that do not use any of those will be considered plaintext replacements such as "|A=B|" (replace all occurrences of "A" with "B").

If you need to use an = within the pattern or text you want to replace you can wrap the pattern inside of a nowiki. ie: {{#replaceset:A=B|<nowiki>=</nowiki>=&}}


{{#replaceset:Text to replace|/(\w+)/i="\1"|to=2}}

Would produce "Text" "2" "replace".


  • ダウンロードして、ファイルを extensions/ フォルダー内の ReplaceSet という名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php の末尾に追加します:
    require_once "$IP/extensions/ReplaceSet/ReplaceSet.php";
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。


{{#replaceset}} has two configurable limitations:

A limit to the number of times #replaceset may be used in a page. This is set to 25 by default.
A limit passed to preg limiting the number of replacements within the text to replace that will be made. This is set to 50 by default.