View source for Action: MassRegexReplace

#||
||
Compatible with: !!(green)**R6.1**!!
Current version: 0.3
Credits: ((user:WikiAdmin WikiAdmin))

|{{toc numerate=1}} ||
||#

Mass edit using regular expressions

##~{{admin_massregex}}##

((source:master/community/action/admin_massregex.php action/admin_massregex.php))
((source:master/community/action/template/admin_massregex.tpl action/template/admin_massregex.tpl))


===Documentation===
Only members of the Admins group can use this action.

===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

file:massregex_1.png

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 [[https://www.php.net/manual/en/function.preg-replace.php preg_replace()]] for details.

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

file:massregex_2.png

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

Pattern Syntax: https://www.php.net/manual/en/reference.pcre.pattern.syntax.php

Regex modifiers: https://www.php.net/manual/en/reference.pcre.pattern.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.

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

===To Do===
  * open task

===See also===
  * ((/Doc/English/Actions/AdminReplace AdminReplace)) - global string find-and-replace

{{backlinks}}