Extension:RegexParserFunctions
From MediaWiki.org
|
RegexParserFunctions Release status: beta |
|
|---|---|
| Implementation | Parser function |
| Description | Adds a {{#regex}} parser function for evaluating regular expressions. |
| Author(s) | Jim R. Wilson (Jimbojw) |
| Last version | 0.1 |
| MediaWiki | 1.6.x, 1.9.x or higher |
| License | The MIT License |
| Download | RegexParserFunctions.php |
|
Check usage (experimental) |
|
RegexParserFunctions adds a parser function called 'regex' (or 'regexp') which is used to perform regular expression pattern matching and replacement.
- Project Homepage
- RegexParserFunctions Extension - Jimbojw.com
- Source Code
- RegexParserFunctions.php
- Licensing
- RegexParserFunctions is released under The MIT License.
[edit] Installation
- Download RegexParserFunctions, and be sure to rename the downloaded file to RegexParserFunctions.php.
- Drop this script in $IP/extensions
- Note: $IP is your MediaWiki install dir.
- Enable the extension by adding this line to your LocalSettings.php:
require_once("$IP/extensions/RegexParserFunctions.php");
[edit] Usage
Once installed, editors of your wiki can evaluate regular expressions in one of two ways: simple match, and replacement.
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}}
[edit] Websites that use RegexParserFunctions
[edit] See also
- 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.
- Extension:RegexFunctions - just another regex extension.
- Extension:Regex Fun - newer, compatible regex extension providing
#regexas well as some other functions.
