Action: MassRegexReplace
Compatible with: R6.1 Current version: 0.3 Credits: WikiAdmin |
Mass edit using regular expressions
{{admin_massregex}}
action/admin_massregex.php
action/template/admin_massregex.tpl
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() 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
Regex modifiers: https://www.php.net/manual/en/[...]attern.modifiers.php
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
- open task
5. See also
- AdminReplace - global string find-and-replace