WackoWiki: Action: MassRegexReplace

https://wackowiki.org/doc     Version: 28 (26.10.2023 17:35)

Action: MassRegexReplace

Compatible with: R6.1
Current version: 0.3
Credits: WikiAdmin[link1]


Mass edit using regular expressions

{{admin_massregex}}

action/admin_massregex.php[link2]
action/template/admin_massregex.tpl[link3]

1. Documentation

Only members of the Admins group can use this action.

2. How to

{{admin_massregex
	[page="PageName"]
	[options=1]
	[lang="en"]
	[mute=1]
	[max=NUMBER]
}}	


[A] search & replace form
[B] target matches selection form
[C] replace target text with replacement



Enter one or more regular expressions (one per line) for matching, and one or more expressions to replace each match with. The first match-expression, if successful, will be replaced with the first replace-expression, and so on. See the PHP function preg_replace()[link4] for details.

Add some examples here...
/hello (.*)\n/		->		goodbye $1
/bird/			->		parrot	



2.1. Regex Gotchas

https://regex101.com/ - Online regex tester and debugger

Pattern Syntax: https://www.php.net/manual/en/[...]e.pattern.syntax.php[link5]

Regex modifiers: https://www.php.net/manual/en/[...]attern.modifiers.php[link6]

Important modifiers to be chosen are:

i (PCRE_CASELESS)
If this modifier is set, letters in the pattern match both upper and lower case letters.

m (PCRE_MULTILINE)
By default, PCRE treats the subject string as consisting of a single "line" of characters (even if it actually contains several newlines). The "start of line" metacharacter (^) matches only at the start of the string, while the "end of line" metacharacter ($) matches only at the end of the string, or before a terminating newline (unless D modifier is set). This is the same as Perl. When this modifier is set, the "start of line" and "end of line" constructs match immediately following or immediately before any newline in the subject string, respectively, as well as at the very start and end. This is equivalent to Perl's /m modifier. If there are no "\n" characters in a subject string, or no occurrences of ^ or $ in a pattern, setting this modifier has no effect.

u (PCRE_UTF8) should be enabled for all possible regexps as we use UTF-8.

3. Changelog

0.1 Intitial version
0.2 allows namespace and category selection
0.3 keeps categories and pages

4. To Do

5. See also


Referring pages:

  1. Dev/PatchesHacks[link8]
  2. Dev/Release/R6.1/ReleaseNotes[link9]
  3. Dev/ReleaseNotes[link10]
  4. Doc/English/Actions/AdminReplace[link11]