Extension:RegexParserFunctions
RegexParserFunctions Release status: stable |
|
---|---|
Implementation | Parser function |
Description | Adds a {{#regex}} parser function for evaluating regular expressions. |
Author(s) | Jim R. Wilson (Jimbojw), Vitaliy Filippov |
Latest version | 0.1 |
MediaWiki | 1.6-1.22 and higher |
License | The MIT License |
Download | https://github.com/mediawiki4intranet/RegexParserFunctions |
Translate the RegexParserFunctions extension if it is available at translatewiki.net |
|
Check usage and version matrix; code metrics |
The RegexParserFunctions extension adds a parser function called 'regex' (or 'regexp') which is used to perform regular expression pattern matching and replacement.
The extension in unmaintained by the original author, but is now maintained by me (User:VitaliyFilippov) as a part of Mediawiki4Intranet project. The security issue found by User:Pastakhov (one with the null-byte) is fixed in our version, and the extension is compatible with latest versions of MediaWiki.
- Git repository
- https://github.com/mediawiki4intranet/RegexParserFunctions
- New homepage
- http://wiki.4intra.net/RegexParserFunctions
- Old homepage
- http://jimbojw.com/wiki/index.php?title=RegexParserFunctions_Extension
- Licensing
- RegexParserFunctions is released under The MIT License.
Installation[edit | edit source]
- Clone the repository from https://github.com/mediawiki4intranet/RegexParserFunctions into $IP/extensions/ subdirectory
- Note: $IP is your MediaWiki install dir.
- Enable the extension by adding this line to your LocalSettings.php:
require_once("$IP/extensions/RegexParserFunctions/RegexParserFunctions.php");
Usage[edit | edit source]
Once installed, editors of your wiki can evaluate regular expressions in one of two ways: simple match, and replacement.
- Simple match: {{#regex: <string> | <regex>}}, evaluates to the matching portion of <string>
- Replacement: {{#regex: <string> | <regex> | <replacement>}}, evaluates to <string> with <regex> replaced by <replacement> globally
For example, say you're trying to grab the last portion of a Title which is using '/' delimiting subpage notation. For that, you could use:
{{#regex:{{PAGENAME}}|%^.*/(.*)$%|$1}}
Websites that use RegexParserFunctions[edit | edit source]
See also[edit | edit source]
- ReplaceSet - an excellent substitute for using nested #replace commands when you need to perform a sequence of replaces on a single text string.
- StringFunctions - some helpful string operations.
- Special:MyLanguage/Extension:RegexFunctions - just another regex extension.
- Special:MyLanguage/Extension:Regex Fun - newer, compatible regex extension providing
#regex
as well as some other functions.
Language: | English • 日本語 |
---|