Extension:StringFunctionsEscaped

What can this extension do?
Wikitext allows the imbedding of certain control characters (newline, tab, etc.). These parser functions allow them to be identified and used with standard c-type escape character sequence ( \n,\t, etc.).

These can be used (among other things) to make infoblox-type templates much more WYSIWIG (see examples) for novice/non-technical users.

Usage
These functions are all invoked exactly as their string parser functions would be (except with the '_e' appended to distinguish).

pos_e: (string position)
Returns the first position of key inside the given value, or an empty string. If offset is defined, this method will not search the first offset characters.

See: http://php.net/manual/function.strpos.php

rpos_e: (string position, reverse)
Returns the last position of key inside the given value, or -1 if the key is not found. When using this to search for the last delimiter, add +1 to the result to retreive position after the last delimiter. This also works when the delimiter is not found, because "-1 + 1" is zero, which is the beginning of the given value.

See: http://php.net/manual/function.strrpos.php

pad_e: (pad string)
Returns the value padded to the certain length with the given with string. If the with string is not given, spaces are used for padding. The direction may be specified as: 'left', 'center' or 'right'.

See: http://php.net/manual/function.str-pad.php

replace_e: (string replace)
Returns the given value with all occurences of 'from' replaced with 'to'.

See: http://php.net/manual/function.str-replace.php

explode_e: (explode string)
Splits the given value into pieces by the given delimiter and returns the position-th piece. Empty string is returned if there are not enough pieces.

Note: Pieces are counted from 0. Note: A negative value can be used to count pieces from the end, instead of counting from the beginning. The last piece is at position -1.

See: http://php.net/manual/function.explode.php

Download instructions
Please cut and paste the code found in SVN and place it in. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation
String functions were integrated into Extension:ParserFunctions extension as of r50997. This revision of Extension:ParserFunctions is designed for MediaWiki 1.16, but updating to the trunk version may work on previous versions. If you are using a prior version of Extension:ParserFunctions, you will also have to include Extension:StringFunctions.

Install and test Extension:ParserFunctions and (if necessary) Extension:StringFunctions prior to installing this extension.

This extension must be included AFTER the invocation of the string parser functions. To install this extension, add the following to LocalSettings.php:

pos_e
Returns:

13

rpos_e
Returns:

13

pad_e
Returns:

xox

replace_e
Returns:

Line 1 Line 2 Line 3

Which would display as:

Line 1 Line 2 Line 3

Rather than the unescaped:

Line 1 Line 2 Line 3

explode_e
Returns:

Line 2