Extension:RegexFunctions/zh

The RegexFunctions extension provides regular expression based parser functions.

用法
As of now, this extension defines three parser functions, rmatch, rsplit, and rreplace


 * string (必需): The text the function uses for the matching.
 * pattern (必需): The regular expression to use on the text.
 * return (必需): What to return if the match was successful. $# and \# contain the captured text, and $$# and \\# contain the offsets of that text. Use ${#}# or \{#}# if you want a group followed by another number.
 * notfound (可选): What to return if the match was not successful. 默认为空字符串.
 * offset (可选): The offset in bytes to start the match at. Defaults to 0 (the beginning of the text).
 * notfound (可选): What to return if the match was not successful. 默认为空字符串.
 * offset (可选): The offset in bytes to start the match at. Defaults to 0 (the beginning of the text).


 * string (必需): The text the function will split.
 * pattern (必需): The regular expression to use on the text. No text is captured.
 * piece (可选): The piece to return. Defaults to 0 (the first piece).
 * pattern (必需): The regular expression to use on the text. No text is captured.
 * piece (可选): The piece to return. Defaults to 0 (the first piece).


 * string (必需): The text the function will replace.
 * pattern (必需): The regular expression to use on the text.
 * replace (必需): The text to replace the matched text with. Both $# and \# will call the capturing groups, use ${#}# or \{#}# if you want a group followed by another number.
 * pattern (必需): The regular expression to use on the text.
 * replace (必需): The text to replace the matched text with. Both $# and \# will call the capturing groups, use ${#}# or \{#}# if you want a group followed by another number.

Pattern help
For help on constructing the syntax, please read for general help and  for an overview of the modifiers.

配置

 * How many functions are allowed per page. Default is 10, but it is recommended that it is set above 3 for usability.
 * How many functions are allowed per page. Default is 10, but it is recommended that it is set above 3 for usability.


 * Allows modifiers (e.g./i for case insensitivity). Does not enable the /e modifier in the rreplace function, see the next variable for that. 默认为“true”.
 * Allows modifiers (e.g./i for case insensitivity). Does not enable the /e modifier in the rreplace function, see the next variable for that. 默认为“true”.


 * Allows modifiers (e.g./i for case insensitivity). Does not enable the /e modifier in the rreplace function, see the next variable for that. 默认为“true”.
 * Allows modifiers (e.g./i for case insensitivity). Does not enable the /e modifier in the rreplace function, see the next variable for that. 默认为“true”.


 * Allows the /e modifier in rreplace, which treats the 'replace' text as PHP code. Don't enable this unless you trust all of your users, as it opens up XSS vectors and other security concerns. 默认为“false”.
 * Allows the /e modifier in rreplace, which treats the 'replace' text as PHP code. Don't enable this unless you trust all of your users, as it opens up XSS vectors and other security concerns. 默认为“false”.


 * Allows internal options (e.g. (?U) for ungreedy) inside of the regex itself. 默认为“false”.
 * Allows internal options (e.g. (?U) for ungreedy) inside of the regex itself. 默认为“false”.


 * Limit for the number of pieces in the rsplit function and replaces in the rreplace function. -1 is unlimited. Defaults to -1.
 * Limit for the number of pieces in the rsplit function and replaces in the rreplace function. -1 is unlimited. Defaults to -1.


 * 您要禁用的功能数组. 默认为空数组.
 * 您要禁用的功能数组. 默认为空数组.

更新日志

 * Version 1.5.0
 * Removed backwards compatible I18n shim.


 * Version 1.4.3
 * Fixed critical security issue (patch by User:Pastakhov).


 * Version 1.4.2
 * Fixed issue in PHP 5.3 about pass-by-reference stuff in the rreplace function.


 * Version 1.4.1
 * Fixed issue where disabling rmatch disabled every function, and it was otherwise impossible to disable rsplit and rreplace.


 * Version 1.4.0
 * Moved to new message declaration style, nothing changed frontend-wise


 * Version 1.3.0
 * Sanitation process should no longer misinterpret things as internal options.


 * Version 1.2.0
 * Pattern goes through a sanitation process before being passed onto one of the preg_* functions.


 * Version 1.1.0
 * Localization updates


 * Version 1.0.0
 * Initial Release, defines three functions: rmatch, rsplit, and rreplace

参见

 * - an excellent substitute for using nested #replace commands when you need to perform a sequence of replaces on a single text string.
 * - some helpful string operations.
 * - just another regex extension with more functionality but without any customization variables for limitations.