<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://www.openwetware.org/skins/common/feed.css?164"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.openwetware.org/index.php?title=OpenWetWare:Software/Extensions/StringFunctions&amp;feed=atom&amp;action=history</id>
		<title>OpenWetWare:Software/Extensions/StringFunctions - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.openwetware.org/index.php?title=OpenWetWare:Software/Extensions/StringFunctions&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://www.openwetware.org/index.php?title=OpenWetWare:Software/Extensions/StringFunctions&amp;action=history"/>
		<updated>2013-05-20T06:38:16Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.13.2</generator>

	<entry>
		<id>http://www.openwetware.org/index.php?title=OpenWetWare:Software/Extensions/StringFunctions&amp;diff=168095&amp;oldid=prev</id>
		<title>Bill Flanagan: New page: =OpenWetWare:Software/Extensions/StringFunctions=   This extension defines an additional set of parser functions that operate on strings.  '''Note: These functio...</title>
		<link rel="alternate" type="text/html" href="http://www.openwetware.org/index.php?title=OpenWetWare:Software/Extensions/StringFunctions&amp;diff=168095&amp;oldid=prev"/>
				<updated>2007-11-17T22:34:06Z</updated>
		
		<summary type="html">&lt;p&gt;New page: =OpenWetWare:Software/Extensions/StringFunctions=   This extension defines an additional set of &lt;a href=&quot;/index.php?title=M:Help:Parser_function&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;M:Help:Parser function (not yet written)&quot;&gt;parser functions&lt;/a&gt; that operate on strings.  '''Note: These functio...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=OpenWetWare:Software/Extensions/StringFunctions=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This extension defines an additional set of [[m:Help:Parser function|parser function]]s that operate on strings.&lt;br /&gt;
&lt;br /&gt;
'''Note: These functions are currently not installed at the Wikimedia projects.'''&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
This module defines these functions: &amp;lt;tt&amp;gt;len&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;pos&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rpos&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sub&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;pad&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;replace&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;explode&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;urlencode&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;urldecode&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Some parameters of these functions can be limited through global settings to ensure the functions operate in O(n) time complexity, and are therefore safe against [[w:denial of service|DoS]] attacks. See section [[#Limits|Limits]] below.&lt;br /&gt;
&lt;br /&gt;
===#len:===&lt;br /&gt;
&lt;br /&gt;
The #len function returns the length of the given string.  The syntax is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#len:string}}&lt;br /&gt;
&lt;br /&gt;
The return value is always a number of characters in the ''string''. If no string is specified, the return value is zero.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
* Trailing spaces are not counted. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#len:Icecream     }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns 8.&lt;br /&gt;
* This function is safe with utf-8 multibyte characters. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#len:Žmržlina}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns 8.&lt;br /&gt;
&lt;br /&gt;
===#pos:===&lt;br /&gt;
&lt;br /&gt;
The #pos function returns the position of a given needle within the string. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#pos:string|needle|offset}}&lt;br /&gt;
&lt;br /&gt;
The ''offset'' parameter, if specified, tells a starting position where this function should begin searching.&lt;br /&gt;
&lt;br /&gt;
If the ''needle'' is found, the return value is a zero-based integer of the first position within the ''string''.&lt;br /&gt;
If the ''needle'' is not found, the function returns an empty string.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
* This function is case sensitive.&lt;br /&gt;
* The maximum allowed length of the ''needle'' is limited through [[#$wgStringFunctionsLimitSearch|$wgStringFunctionsLimitSearch]] global setting.&lt;br /&gt;
* This function is safe with utf-8 multibyte characters. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#pos:Žmržlina|lina}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns 4.&lt;br /&gt;
&lt;br /&gt;
===#rpos:===&lt;br /&gt;
&lt;br /&gt;
The #rpos function returns the last position of a given needle within the string. The syntax is:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#rpos:string|needle}}&lt;br /&gt;
&lt;br /&gt;
If the ''needle'' is found, the return value is a zero-based integer of its last position within the ''string''.&lt;br /&gt;
If the ''needle'' is not found, the function returns -1.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' 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 &amp;quot;-1 + 1&amp;quot; is zero, which is the beginning of the given value.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
* This function is case sensitive.&lt;br /&gt;
* The maximum allowed length of the ''needle'' is limited through [[#$wgStringFunctionsLimitSearch|$wgStringFunctionsLimitSearch]] global setting.&lt;br /&gt;
* This function is safe with utf-8 multibyte characters. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#rpos:Žmržlina|lina}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns 4.&lt;br /&gt;
* When this extension is running on PHP 4, the ''needle'' can only be a single character. If a string is used as the ''needle'', only the first character of that string will be used. The ''needle'' may be a string of more than one character as of PHP 5.0.0.&lt;br /&gt;
&lt;br /&gt;
===#sub:===&lt;br /&gt;
&lt;br /&gt;
The #sub function returns a substring from the given string. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;{{#sub:string|start|length}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''start'' parameter, if positive (or zero), specifies a zero-based index of the first character to be returned.&lt;br /&gt;
Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#sub:Icecream|3}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;cream&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If the ''start'' parameter is negative, it specifies how many characters from the end should be returned.&lt;br /&gt;
Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#sub:Icecream|-3}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;eam&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The ''length'' parameter, if present and positive, specifies the maximum length of the returned string.&lt;br /&gt;
Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#sub:Icecream|3|3}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;cre&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If the ''length'' parameter is negative, it specifies, how many characters will be omitted from the end of the string.&lt;br /&gt;
Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#sub:Icecream|3|-3}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;cr&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
* If the ''length'' parameter is zero, it is not used for truncation at all.&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#sub:Icecream|3|0}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;cream&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If ''start'' denotes a position beyond the truncation from the end by negative ''length'' parameter, an empty string will be returned.&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#sub:Icecream|3|-6}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns an empty string.&lt;br /&gt;
** The return value is a substring from the string, or an empty string.&lt;br /&gt;
* This function is safe with utf-8 multibyte characters. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#sub:Žmržlina|3}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;žlina&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===#pad:===&lt;br /&gt;
&lt;br /&gt;
The #pad function returns the given string extended to a given width. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#pad:string|length|padstring|direction}}&lt;br /&gt;
&lt;br /&gt;
The ''length'' parameter specifies the desired length of the returned string.&lt;br /&gt;
&lt;br /&gt;
The ''padstring'' parameter, if specified, specifies a pattern to be used to fill the missing space. It may be a single character, which will be used as many times as necessary; or a string which will be concatenated as many times as necessary and then trimed to the required length.&lt;br /&gt;
Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#pad:Ice|10|xX}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;XxXxXxXIce&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If the ''padstring'' is not specified, spaces are used for padding.&lt;br /&gt;
&lt;br /&gt;
The ''direction'' parameter, if specified, can be one of these values:&lt;br /&gt;
* &amp;lt;tt&amp;gt;left&amp;lt;/tt&amp;gt; - the padding will be on the left side of the string. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#pad:Ice|5|x|left}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;xxIce&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;right&amp;lt;/tt&amp;gt; - the padding will be on the right side of the string. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#pad:Ice|5|x|right}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;Icexx&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;center&amp;lt;/tt&amp;gt; - the string will be centered in the returned string. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#pad:Ice|5|x|center}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;xIcex&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If the ''direction'' is not specified, the padding will be on the left side of the string.&lt;br /&gt;
&lt;br /&gt;
The return value is the given string extended to the ''length'' of characters, using the ''padstring'' to fill the missing part(s).&lt;br /&gt;
If the given string is already longer than ''length'', it is not extended, nor truncated.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
* The maximum allowed value for the ''length'' is limited through [[#$wgStringFunctionsLimitPad|$wgStringFunctionsLimitPad]] global setting.&lt;br /&gt;
* This function is NOT safe with utf-8 multibyte characters (i.e. non-english characters). Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#pad:Žmržlina|12|x}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;xxŽmržlina&amp;lt;/tt&amp;gt; (instead of &amp;lt;tt&amp;gt;xxxxŽmržlina&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
===#replace:===&lt;br /&gt;
&lt;br /&gt;
The #replace function returns the given string with all occurrences of a needle replaced with product.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#replace:string|needle|product}}&lt;br /&gt;
&lt;br /&gt;
If the ''needle'' is not specified, or is empty a single space will be searched for.&lt;br /&gt;
&lt;br /&gt;
If the ''product'' is not specified, or is empty, all occurrences of the ''needle'' will be removed from the ''string''.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
* This function is case sensitive.&lt;br /&gt;
* Even if the ''product'' is a space, an empty string is used. This is a side-effect of the MediaWiki parser feature. To use a space as the ''product'', put it in a nowiki tags.&lt;br /&gt;
**Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#replace:My_little_home_page|_|&amp;lt;nowiki&amp;gt; &amp;lt;/&amp;lt;/nowiki&amp;gt;nowiki&amp;lt;nowiki&amp;gt;&amp;gt;}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;My little home page&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* The maximum allowed length of the ''needle'' is limited through [[#$wgStringFunctionsLimitSearch|$wgStringFunctionsLimitSearch]] global setting.&lt;br /&gt;
* The maximum allowed length of the ''product'' is limited through [[#$wgStringFunctionsLimitReplace|$wgStringFunctionsLimitReplace]] global setting.&lt;br /&gt;
* This function is safe with utf-8 multibyte characters. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#replace:Žmržlina|ž|z}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;Žmrzlina&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===#explode:===&lt;br /&gt;
&lt;br /&gt;
The #explode functions splits the given string into pieces and then returns one of the pieces. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#explode:string|delimiter|position}}&lt;br /&gt;
&lt;br /&gt;
The ''delimiter'' parameter specifies a string to be used to divide the ''string'' into pieces. This ''delimiter'' string is then not part of any piece, and when two ''delimiter'' strings are next to each other, they create an empty piece between them. If this parameter is not specified, a single space is used.&lt;br /&gt;
&lt;br /&gt;
The ''position'' parameter specifies, which piece is to be returned. Pieces are counted from 0. If this parameter is not specified, the first piece is used (piece with number 0). When a negative value is used as ''position'', the pieces are counted from the end. In this case, piece with number -1 means the last piece. Examples:&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#explode:And if you tolerate this| |2}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;you&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#explode:String/Functions/Code|/|-1}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;Code&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The return value is the ''position''-th piece. If there are less pieces than the ''position'' specifies, an empty string is returned.&lt;br /&gt;
&lt;br /&gt;
'''Notes:'''&lt;br /&gt;
* This function is case sensitive.&lt;br /&gt;
* The maximum allowed length of the ''delimiter'' is limited through [[#$wgStringFunctionsLimitSearch|$wgStringFunctionsLimitSearch]] global setting.&lt;br /&gt;
* This function is safe with utf-8 multibyte characters. Example: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#explode:Žmržlina|ž|1}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; returns &amp;lt;tt&amp;gt;lina&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===#urlencode: and #urldecode:===&lt;br /&gt;
&lt;br /&gt;
These two functions operate in tandem: #urlencode converts a string into an URL-safe syntax, and #urldecode converts such a string back. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#urlencode:value}}&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#urldecode:value}}&lt;br /&gt;
&lt;br /&gt;
'''Note:''' These functions work by directly exposing PHP's [http://php.net/manual/en/function.urlencode.php urlencode()] and [http://php.net/manual/en/function.urldecode.php urldecode()] functions.&lt;br /&gt;
&lt;br /&gt;
==Usage tips==&lt;br /&gt;
&lt;br /&gt;
===Pipes===&lt;br /&gt;
&lt;br /&gt;
To use a pipe ( &amp;quot;|&amp;quot; ) in the parameters in these functions, try the &amp;lt;b&amp;gt;&amp;amp;#&amp;lt;/b&amp;gt;&amp;lt;b&amp;gt;124;&amp;lt;/b&amp;gt; sequence, which is translated to a regular pipe before these functions are executed, but only after the control pipes are established by the parser. This way the pipes will be treated as pieces of string, not like wiki syntax.&lt;br /&gt;
&lt;br /&gt;
===Spaces===&lt;br /&gt;
&lt;br /&gt;
To use a space in the parameters in these functions (at the beginning or end of the parameters), you might need to put the space in the &amp;lt;b&amp;gt;&amp;lt;&amp;lt;/b&amp;gt;&amp;lt;b&amp;gt;nowiki&amp;gt;&amp;lt;/&amp;lt;/b&amp;gt;&amp;lt;b&amp;gt;nowiki&amp;gt;&amp;lt;/b&amp;gt; tags. This will prevent the parser from trimming the space off before calling the functions.&lt;br /&gt;
&lt;br /&gt;
==Limits==&lt;br /&gt;
&lt;br /&gt;
This module defines these global settings: &amp;lt;tt&amp;gt;$wgStringFunctionsLimitSearch&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;$wgStringFunctionsLimitReplace&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;$wgStringFunctionsLimitPad&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
They are used to limit some parameters of some functions to ensure the functions operate in O(n) time complexity, and are therefore safe against [[w:denial of service|DoS]] attacks.&lt;br /&gt;
&lt;br /&gt;
===$wgStringFunctionsLimitSearch===&lt;br /&gt;
&lt;br /&gt;
This setting is used by [[##pos:|#pos:]], [[##rpos:|#rpos:]], [[##replace:|#replace:]], [[##explode:|#explode:]] functions. All these functions search for a substring in a larger string while they operate, which can run in O(n*m), and therefore they make the software more voulnerable to [[w:denial of service|DoS]] attacks. By setting this value to a specific small number, the time complexity is decreased to O(n).&lt;br /&gt;
&lt;br /&gt;
This setting limits the maximum allowed length of the string being searched for.&lt;br /&gt;
&lt;br /&gt;
The default value is 30 multibyte characters.&lt;br /&gt;
&lt;br /&gt;
===$wgStringFunctionsLimitReplace===&lt;br /&gt;
&lt;br /&gt;
This setting is used by [[##replace:|#replace:]] function. This function replaces all occurences of one string for another, which can be used to quickly generate very large amounts of data, and therefore it can make the software more voulnerable to [[w:denial of service|DoS]] attacks. This setting limits the maximum allowed length of the replacing string.&lt;br /&gt;
&lt;br /&gt;
The default value is 30 multibyte characters.&lt;br /&gt;
&lt;br /&gt;
===$wgStringFunctionsLimitPad===&lt;br /&gt;
&lt;br /&gt;
This setting is used by [[##pad:|#pad:]] function. This function creates a string by the specified length, which can be used to quickly generate very large amounts of data, and therefore it can make the software more voulnerable to [[w:denial of service|DoS]] attacks. This setting limits the maximum allowed length of the resulting padded string.&lt;br /&gt;
&lt;br /&gt;
The default value is 100 multibyte characters.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
===Requirements===&lt;br /&gt;
This extension requires MediaWiki 1.6+ and the [http://php.net/manual/ref.mbstring.php PHP mbstring extension].&lt;br /&gt;
&lt;br /&gt;
If you do not have mbstring installed, you can do without by deleting all occurrences of &amp;quot;&amp;lt;code&amp;gt;mb_&amp;lt;/code&amp;gt;&amp;quot; (without quotes) in the code, which will replace all mbstring functions (mb_strlen, mb_substr, mb_strpos, mb_strrpos) by their non-mbstring equivalents. By doing this, the extension will no longer work correctly with utf-8 multibyte characters (e.g. non-English letters), but it will work.&lt;br /&gt;
&lt;br /&gt;
===Instructions===&lt;br /&gt;
Do the following to install these functions as an extension to MediaWiki.&lt;br /&gt;
# Copy the source code [[#Code|below]] to &amp;lt;tt&amp;gt;extensions/StringFunctions/StringFunctions.php&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Add the following to &amp;lt;tt&amp;gt;[[LocalSettings.php]]&amp;lt;/tt&amp;gt; (near the bottom) in the root of your MediaWiki installation:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;require_once (&amp;quot;$IP/extensions/StringFunctions/StringFunctions.php&amp;quot;);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Compatibility with MediaWiki 1.6====&lt;br /&gt;
All StringFunctions will work on MediaWiki 1.6, but their syntax is without the # character. If you want to use the # character, find this section of the &amp;lt;tt&amp;gt;/extensions/StringFunctions/StringFunctions.php&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( 'len',       array ( &amp;amp;$wgExtStringFunctions, 'runLen'       ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( 'pos',       array ( &amp;amp;$wgExtStringFunctions, 'runPos'       ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( 'rpos',      array ( &amp;amp;$wgExtStringFunctions, 'runRPos'      ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( 'sub',       array ( &amp;amp;$wgExtStringFunctions, 'runSub'       ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( 'pad',       array ( &amp;amp;$wgExtStringFunctions, 'runPad'       ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( 'replace',   array ( &amp;amp;$wgExtStringFunctions, 'runReplace'   ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( 'explode',   array ( &amp;amp;$wgExtStringFunctions, 'runExplode'   ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( 'urlencode', array ( &amp;amp;$wgExtStringFunctions, 'runUrlEncode' ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( 'urldecode', array ( &amp;amp;$wgExtStringFunctions, 'runUrlDecode' ) );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace the above with this:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( '#len',       array ( &amp;amp;$wgExtStringFunctions, 'runLen'       ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( '#pos',       array ( &amp;amp;$wgExtStringFunctions, 'runPos'       ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( '#rpos',      array ( &amp;amp;$wgExtStringFunctions, 'runRPos'      ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( '#sub',       array ( &amp;amp;$wgExtStringFunctions, 'runSub'       ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( '#pad',       array ( &amp;amp;$wgExtStringFunctions, 'runPad'       ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( '#replace',   array ( &amp;amp;$wgExtStringFunctions, 'runReplace'   ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( '#explode',   array ( &amp;amp;$wgExtStringFunctions, 'runExplode'   ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( '#urlencode', array ( &amp;amp;$wgExtStringFunctions, 'runUrlEncode' ) );&lt;br /&gt;
$wgParser-&amp;gt;setFunctionHook ( '#urldecode', array ( &amp;amp;$wgExtStringFunctions, 'runUrlDecode' ) );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
This code has been tested on MediaWiki 1.6.8 and above.&lt;br /&gt;
&lt;br /&gt;
History:&lt;br /&gt;
* Aug 28, 2007 -- v1.10 -- Added negative positions to #explode.&lt;br /&gt;
* Jan 30, 2007 -- v1.9 -- Added limits to #pos, #pad, #replace, #explode.&lt;br /&gt;
* Oct 30, 2006 -- v1.8 -- Fixed for MediaWiki 1.8.&lt;br /&gt;
* Oct 26, 2006 -- v1.6 -- Fixed spaces in #rpos and #replace.&lt;br /&gt;
* Oct 1,  2006 -- v1.5 -- Added #rpos, #pad, #replace, #explode.&lt;br /&gt;
* May 18, 2006 -- v1.2 -- Renamed #toURL and #fromURL to match MediaWiki's [http://svn.wikimedia.org/viewvc/mediawiki?view=rev&amp;amp;revision=14273 &amp;amp;#123;&amp;amp;#123;urlencode:}}] function.&lt;br /&gt;
* May 18, 2006 -- v1.1 -- Added #pos.&lt;br /&gt;
* May 15, 2006 -- v1.0 -- First stable release.&lt;br /&gt;
&lt;br /&gt;
{{:Extension:StringFunctions/Code}}&lt;br /&gt;
&lt;br /&gt;
==Applications==&lt;br /&gt;
* Constructing a suitable sortkey from a page name in a category tag in the transcluded part of a template.&lt;br /&gt;
* Listing page name variations to simulate [[redirect]] inclusions of [[Special:Whatlinkshere]] in [[Dynamic Page List]].&lt;br /&gt;
* More?&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[m:ParserFunctions|ParserFunctions]]&lt;br /&gt;
*[[Extension:VariablesExtension|VariablesExtension]]&lt;br /&gt;
*[[Extension:DynamicFunctions|DynamicFunctions]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Extensions]]&lt;/div&gt;</summary>
		<author><name>Bill Flanagan</name></author>	</entry>

	</feed>
