<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
		<id>https://www.ekopedia.fr/index.php?action=history&amp;feed=atom&amp;title=Module%3AString</id>
		<title>Module:String - Historique des versions</title>
		<link rel="self" type="application/atom+xml" href="https://www.ekopedia.fr/index.php?action=history&amp;feed=atom&amp;title=Module%3AString"/>
		<link rel="alternate" type="text/html" href="https://www.ekopedia.fr/index.php?title=Module:String&amp;action=history"/>
		<updated>2026-04-19T09:11:04Z</updated>
		<subtitle>Historique pour cette page sur le wiki</subtitle>
		<generator>MediaWiki 1.27.1</generator>

	<entry>
		<id>https://www.ekopedia.fr/index.php?title=Module:String&amp;diff=126226&amp;oldid=prev</id>
		<title>- Hermes - : creation</title>
		<link rel="alternate" type="text/html" href="https://www.ekopedia.fr/index.php?title=Module:String&amp;diff=126226&amp;oldid=prev"/>
				<updated>2021-10-13T17:24:28Z</updated>
		
		<summary type="html">&lt;p&gt;creation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
&lt;br /&gt;
This module is intended to provide access to basic string functions.&lt;br /&gt;
&lt;br /&gt;
Most of the functions provided here can be invoked with named parameters,&lt;br /&gt;
unnamed parameters, or a mixture.  If named parameters are used, Mediawiki will&lt;br /&gt;
automatically remove any leading or trailing whitespace from the parameter.&lt;br /&gt;
Depending on the intended use, it may be advantageous to either preserve or&lt;br /&gt;
remove such whitespace.&lt;br /&gt;
&lt;br /&gt;
Global options&lt;br /&gt;
	ignore_errors: If set to 'true' or 1, any error condition will result in&lt;br /&gt;
		an empty string being returned rather than an error message.&lt;br /&gt;
		&lt;br /&gt;
	error_category: If an error occurs, specifies the name of a category to&lt;br /&gt;
		include with the error message.  The default category is&lt;br /&gt;
		[Category:Errors reported by Module String].&lt;br /&gt;
		&lt;br /&gt;
	no_category: If set to 'true' or 1, no category will be added if an error&lt;br /&gt;
		is generated.&lt;br /&gt;
		&lt;br /&gt;
Unit tests for this module are available at Module:String/tests.&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local str = {}&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
len&lt;br /&gt;
&lt;br /&gt;
This function returns the length of the target string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|len|target_string|}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|len|s=target_string}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	s: The string whose length to report&lt;br /&gt;
&lt;br /&gt;
If invoked using named parameters, Mediawiki will automatically remove any leading or&lt;br /&gt;
trailing whitespace from the target string.&lt;br /&gt;
]]&lt;br /&gt;
function str.len( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {'s'} )&lt;br /&gt;
	local s = new_args['s'] or ''&lt;br /&gt;
	return mw.ustring.len( s )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
sub&lt;br /&gt;
&lt;br /&gt;
This function returns a substring of the target string at specified indices.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|sub|target_string|start_index|end_index}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|sub|s=target_string|i=start_index|j=end_index}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	s: The string to return a subset of&lt;br /&gt;
	i: The fist index of the substring to return, defaults to 1.&lt;br /&gt;
	j: The last index of the string to return, defaults to the last character.&lt;br /&gt;
	&lt;br /&gt;
The first character of the string is assigned an index of 1.  If either i or j&lt;br /&gt;
is a negative value, it is interpreted the same as selecting a character by&lt;br /&gt;
counting from the end of the string.  Hence, a value of -1 is the same as&lt;br /&gt;
selecting the last character of the string.&lt;br /&gt;
&lt;br /&gt;
If the requested indices are out of range for the given string, an error is&lt;br /&gt;
reported.&lt;br /&gt;
]]&lt;br /&gt;
function str.sub( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, { 's', 'i', 'j' } )&lt;br /&gt;
	local s = new_args['s'] or ''&lt;br /&gt;
	local i = tonumber( new_args['i'] ) or 1&lt;br /&gt;
	local j = tonumber( new_args['j'] ) or -1&lt;br /&gt;
	&lt;br /&gt;
	local len = mw.ustring.len( s )&lt;br /&gt;
&lt;br /&gt;
	-- Convert negatives for range checking&lt;br /&gt;
	if i &amp;lt; 0 then&lt;br /&gt;
		i = len + i + 1&lt;br /&gt;
	end&lt;br /&gt;
	if j &amp;lt; 0 then&lt;br /&gt;
		j = len + j + 1&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if i &amp;gt; len or j &amp;gt; len or i &amp;lt; 1 or j &amp;lt; 1 then&lt;br /&gt;
		return str._error( 'String subset index out of range' )&lt;br /&gt;
	end&lt;br /&gt;
	if j &amp;lt; i then&lt;br /&gt;
		return str._error( 'String subset indices out of order' )&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return mw.ustring.sub( s, i, j )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
This function implements that features of {{str sub old}} and is kept in order&lt;br /&gt;
to maintain these older templates.&lt;br /&gt;
]]&lt;br /&gt;
function str.sublength( frame )&lt;br /&gt;
	local i = tonumber( frame.args.i ) or 0&lt;br /&gt;
	local len = tonumber( frame.args.len )&lt;br /&gt;
	return mw.ustring.sub( frame.args.s, i + 1, len and ( i + len ) )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
match&lt;br /&gt;
&lt;br /&gt;
This function returns a substring from the source string that matches a&lt;br /&gt;
specified pattern.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|pos|s=source_string|pattern=pattern_string|start=start_index&lt;br /&gt;
	|match=match_number|plain=plain_flag|nomatch=nomatch_output}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	s: The string to search&lt;br /&gt;
	pattern: The pattern or string to find within the string&lt;br /&gt;
	start: The index within the source string to start the search.  The first&lt;br /&gt;
		character of the string has index 1.  Defaults to 1.&lt;br /&gt;
	match: In some cases it may be possible to make multiple matches on a single&lt;br /&gt;
		string.  This specifies which match to return, where the first match is&lt;br /&gt;
		match= 1.  If a negative number is specified then a match is returned&lt;br /&gt;
		counting from the last match.  Hence match = -1 is the same as requesting&lt;br /&gt;
		the last match.  Defaults to 1.&lt;br /&gt;
	plain: A flag indicating that the pattern should be understood as plain&lt;br /&gt;
		text.  Defaults to false.&lt;br /&gt;
	nomatch: If no match is found, output the &amp;quot;nomatch&amp;quot; value rather than an error.&lt;br /&gt;
&lt;br /&gt;
If invoked using named parameters, Mediawiki will automatically remove any leading or&lt;br /&gt;
trailing whitespace from each string.  In some circumstances this is desirable, in&lt;br /&gt;
other cases one may want to preserve the whitespace.&lt;br /&gt;
&lt;br /&gt;
If the match_number or start_index are out of range for the string being queried, then&lt;br /&gt;
this function generates an error.  An error is also generated if no match is found.&lt;br /&gt;
If one adds the parameter ignore_errors=true, then the error will be suppressed and&lt;br /&gt;
an empty string will be returned on any failure.&lt;br /&gt;
&lt;br /&gt;
For information on constructing Lua patterns, a form of [regular expression], see:&lt;br /&gt;
&lt;br /&gt;
* http://www.lua.org/manual/5.1/manual.html#5.4.1&lt;br /&gt;
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns&lt;br /&gt;
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
function str.match( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {'s', 'pattern', 'start', 'match', 'plain', 'nomatch'} )&lt;br /&gt;
	local s = new_args['s'] or ''&lt;br /&gt;
	local start = tonumber( new_args['start'] ) or 1&lt;br /&gt;
	local plain_flag = str._getBoolean( new_args['plain'] or false )&lt;br /&gt;
	local pattern = new_args['pattern'] or ''&lt;br /&gt;
	local match_index = math.floor( tonumber(new_args['match']) or 1 )&lt;br /&gt;
	local nomatch = new_args['nomatch']&lt;br /&gt;
	&lt;br /&gt;
	if s == '' then&lt;br /&gt;
		-- return str._error( 'Target string is empty' )&lt;br /&gt;
	end&lt;br /&gt;
	if pattern == '' then&lt;br /&gt;
		return str._error( 'Pattern string is empty' )&lt;br /&gt;
	end&lt;br /&gt;
	if math.abs(start) &amp;lt; 1 or math.abs(start) &amp;gt; mw.ustring.len( s ) then&lt;br /&gt;
		-- return str._error( 'Requested start is out of range' )&lt;br /&gt;
	end&lt;br /&gt;
	if match_index == 0 then&lt;br /&gt;
		return str._error( 'Match index is out of range' )&lt;br /&gt;
	end&lt;br /&gt;
	if plain_flag then&lt;br /&gt;
		pattern = str._escapePattern( pattern )&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local result&lt;br /&gt;
	if match_index == 1 then&lt;br /&gt;
		-- Find first match is simple case&lt;br /&gt;
		result = mw.ustring.match( s, pattern, start )&lt;br /&gt;
	else&lt;br /&gt;
		if start &amp;gt; 1 then&lt;br /&gt;
			s = mw.ustring.sub( s, start )&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		local iterator = mw.ustring.gmatch(s, pattern)&lt;br /&gt;
		if match_index &amp;gt; 0 then&lt;br /&gt;
			-- Forward search&lt;br /&gt;
			for w in iterator do&lt;br /&gt;
				match_index = match_index - 1&lt;br /&gt;
				if match_index == 0 then&lt;br /&gt;
					result = w&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			-- Reverse search&lt;br /&gt;
			local result_table = {}&lt;br /&gt;
			local count = 1&lt;br /&gt;
			for w in iterator do&lt;br /&gt;
				result_table[count] = w&lt;br /&gt;
				count = count + 1&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			result = result_table[ count + match_index ]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if result == nil then&lt;br /&gt;
		if nomatch == nil then&lt;br /&gt;
			return str._error( 'Match not found' )&lt;br /&gt;
		else&lt;br /&gt;
			return nomatch&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return result&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
pos&lt;br /&gt;
&lt;br /&gt;
This function returns a single character from the target string at position pos.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|pos|target_string|index_value}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|pos|target=target_string|pos=index_value}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	target: The string to search&lt;br /&gt;
	pos: The index for the character to return&lt;br /&gt;
&lt;br /&gt;
If invoked using named parameters, Mediawiki will automatically remove any leading or&lt;br /&gt;
trailing whitespace from the target string.  In some circumstances this is desirable, in&lt;br /&gt;
other cases one may want to preserve the whitespace.&lt;br /&gt;
&lt;br /&gt;
The first character has an index value of 1.&lt;br /&gt;
&lt;br /&gt;
If one requests a negative value, this function will select a character by counting backwards&lt;br /&gt;
from the end of the string.  In other words pos = -1 is the same as asking for the last character.&lt;br /&gt;
&lt;br /&gt;
A requested value of zero, or a value greater than the length of the string returns an error.&lt;br /&gt;
]]&lt;br /&gt;
function str.pos( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {'target', 'pos'} )&lt;br /&gt;
	local target_str = new_args['target'] or ''&lt;br /&gt;
	local pos = tonumber( new_args['pos'] ) or 0&lt;br /&gt;
&lt;br /&gt;
	if pos == 0 or math.abs(pos) &amp;gt; mw.ustring.len( target_str ) then&lt;br /&gt;
		return str._error( 'String index out of range' )&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return mw.ustring.sub( target_str, pos, pos )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
find&lt;br /&gt;
&lt;br /&gt;
This function allows one to search for a target string or pattern within another&lt;br /&gt;
string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|find|source_str|target_string|start_index|plain_flag}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	source: The string to search&lt;br /&gt;
	target: The string or pattern to find within source&lt;br /&gt;
	start: The index within the source string to start the search, defaults to 1&lt;br /&gt;
	plain: Boolean flag indicating that target should be understood as plain&lt;br /&gt;
		text and not as a Lua style regular expression, defaults to true&lt;br /&gt;
&lt;br /&gt;
If invoked using named parameters, Mediawiki will automatically remove any leading or&lt;br /&gt;
trailing whitespace from the parameter.  In some circumstances this is desirable, in&lt;br /&gt;
other cases one may want to preserve the whitespace.&lt;br /&gt;
&lt;br /&gt;
This function returns the first index &amp;gt;= &amp;quot;start&amp;quot; where &amp;quot;target&amp;quot; can be found&lt;br /&gt;
within &amp;quot;source&amp;quot;.  Indices are 1-based.  If &amp;quot;target&amp;quot; is not found, then this&lt;br /&gt;
function returns 0.  If either &amp;quot;source&amp;quot; or &amp;quot;target&amp;quot; are missing / empty, this&lt;br /&gt;
function also returns 0.&lt;br /&gt;
&lt;br /&gt;
This function should be safe for UTF-8 strings.&lt;br /&gt;
]]&lt;br /&gt;
function str.find( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {'source', 'target', 'start', 'plain' } )&lt;br /&gt;
	local source_str = new_args['source'] or ''&lt;br /&gt;
	local pattern = new_args['target'] or ''&lt;br /&gt;
	local start_pos = tonumber(new_args['start']) or 1&lt;br /&gt;
	local plain = new_args['plain'] or true&lt;br /&gt;
		&lt;br /&gt;
	if source_str == '' or pattern == '' then&lt;br /&gt;
		return 0&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	plain = str._getBoolean( plain )&lt;br /&gt;
&lt;br /&gt;
	local start = mw.ustring.find( source_str, pattern, start_pos, plain )&lt;br /&gt;
	if start == nil then&lt;br /&gt;
		start = 0&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return start&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
replace&lt;br /&gt;
&lt;br /&gt;
This function allows one to replace a target string or pattern within another&lt;br /&gt;
string.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|replace|source=source_string|pattern=pattern_string|replace=replace_string|&lt;br /&gt;
   count=replacement_count|plain=plain_flag}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	source: The string to search&lt;br /&gt;
	pattern: The string or pattern to find within source&lt;br /&gt;
	replace: The replacement text&lt;br /&gt;
	count: The number of occurences to replace, defaults to all.&lt;br /&gt;
	plain: Boolean flag indicating that pattern should be understood as plain&lt;br /&gt;
		text and not as a Lua style regular expression, defaults to true&lt;br /&gt;
]]&lt;br /&gt;
function str.replace( frame )&lt;br /&gt;
	local new_args = str._getParameters( frame.args, {'source', 'pattern', 'replace', 'count', 'plain' } )&lt;br /&gt;
	local source_str = new_args['source'] or ''&lt;br /&gt;
	local pattern = new_args['pattern'] or ''&lt;br /&gt;
	local replace = new_args['replace'] or ''&lt;br /&gt;
	local count = tonumber( new_args['count'] )&lt;br /&gt;
	local plain = new_args['plain'] or true&lt;br /&gt;
	&lt;br /&gt;
	if source_str == '' or pattern == '' then&lt;br /&gt;
		return source_str&lt;br /&gt;
	end&lt;br /&gt;
	plain = str._getBoolean( plain )&lt;br /&gt;
&lt;br /&gt;
	if plain then&lt;br /&gt;
		pattern = str._escapePattern( pattern )&lt;br /&gt;
		replace = mw.ustring.gsub( replace, &amp;quot;%%&amp;quot;, &amp;quot;%%%%&amp;quot; ); --Only need to escape replacement sequences.&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local result&lt;br /&gt;
&lt;br /&gt;
	if count ~= nil then&lt;br /&gt;
		result = mw.ustring.gsub( source_str, pattern, replace, count )&lt;br /&gt;
	else&lt;br /&gt;
		result = mw.ustring.gsub( source_str, pattern, replace )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
simpletitle&lt;br /&gt;
&lt;br /&gt;
This function returns the current page title without the homonymy part (the part in parenthesis).&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|simpletitle}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|simpletitle|string}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	string: if present this function will treat this string as the title of the page and remove&lt;br /&gt;
	   homonymy part if present in it. If not given the function uses the page title (without namespace)&lt;br /&gt;
]]&lt;br /&gt;
function str.simpletitle(frame)&lt;br /&gt;
	-- si un paramètre est indiqué, on l'utilise comme titre à traiter&lt;br /&gt;
	-- sinon on utilise le titre de la page actuelle&lt;br /&gt;
	local page = frame.args[1]&lt;br /&gt;
	if (page == nil or page == &amp;quot;&amp;quot;) then&lt;br /&gt;
	  page = mw.title.getCurrentTitle().text&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- on enlève la partie entre parenthèses&lt;br /&gt;
	local npage = mw.ustring.gsub(page, &amp;quot; [(][^()]*[)]$&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	if (npage == nil or npage == &amp;quot;&amp;quot;) then return &amp;quot;&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
	return npage&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
titledisambig&lt;br /&gt;
&lt;br /&gt;
This function returns the part of the title used for disambiguation,&lt;br /&gt;
including the parenthesis themselves and the space just before.&lt;br /&gt;
 &lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:String|titledisambig}}&lt;br /&gt;
OR&lt;br /&gt;
{{#invoke:String|titledisambig|string}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	string: if present this function will treat this string as the title of the page.&lt;br /&gt;
	If not given the function uses the page title.&lt;br /&gt;
]]&lt;br /&gt;
function str.titledisambig(frame)&lt;br /&gt;
	-- si un paramètre est indiqué, on l'utilise comme titre à traiter&lt;br /&gt;
	-- sinon on utilise le titre de la page actuelle&lt;br /&gt;
	local page = frame.args[1]&lt;br /&gt;
	if (page == nil or page == &amp;quot;&amp;quot;) then&lt;br /&gt;
	  page = mw.title.getCurrentTitle().text&lt;br /&gt;
	end&lt;br /&gt;
 &lt;br /&gt;
	-- on retourne la partie entre parenthèses,&lt;br /&gt;
	-- en incluant les parenthèses et l'espace précédente&lt;br /&gt;
	local disambigStart = string.find(page, &amp;quot; %(&amp;quot;)&lt;br /&gt;
	if disambigStart then&lt;br /&gt;
		return string.sub(page, disambigStart)&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
trim&lt;br /&gt;
&lt;br /&gt;
Cette fonction retourne son unique paramètre en supprimant les espaces&lt;br /&gt;
et sauts de ligne au début et à la fin (fonction &amp;quot;trim&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Usage :&lt;br /&gt;
{{#invoke:String|trim|string}}&lt;br /&gt;
&lt;br /&gt;
Paramètres :&lt;br /&gt;
	la chaîne 'string' dont on veut supprimer les éventuels espaces&lt;br /&gt;
	et sauts de ligne au début et/ou à la fin&lt;br /&gt;
]]&lt;br /&gt;
function str.trim(frame)&lt;br /&gt;
	local txt = frame.args[1]&lt;br /&gt;
	if not txt or txt == &amp;quot;&amp;quot; then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	return mw.text.trim(txt)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
rep&lt;br /&gt;
&lt;br /&gt;
Cette fonction retourne la concaténation de son premier paramètre n fois où n est le deuxième paramètre (fonction &amp;quot;rep&amp;quot; ou &amp;quot;repeat&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Usage :&lt;br /&gt;
{{#invoke:String|rep|string|int}}&lt;br /&gt;
&lt;br /&gt;
Paramètres :&lt;br /&gt;
	la chaîne 'string' dont on veut répeter&lt;br /&gt;
	l'entier 'int' le nombre d'itération&lt;br /&gt;
]]&lt;br /&gt;
function str.rep(frame)&lt;br /&gt;
	local new_args = str._getParameters( frame.args, { 's', 'n' } )&lt;br /&gt;
	local s = new_args['s'] or ''&lt;br /&gt;
	local n = tonumber( new_args['n'] ) or 1&lt;br /&gt;
	if not s or s == '' then&lt;br /&gt;
		return ''&lt;br /&gt;
	end&lt;br /&gt;
	if not n or n &amp;lt;0 then&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
	return mw.ustring.rep(s,n)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function that populates the argument list given that user may need to use a mix of&lt;br /&gt;
named and unnamed parameters.  This is relevant because named parameters are not&lt;br /&gt;
identical to unnamed parameters due to string trimming, and when dealing with strings&lt;br /&gt;
we sometimes want to either preserve or remove that whitespace depending on the application.&lt;br /&gt;
]]&lt;br /&gt;
function str._getParameters( frame_args, arg_list )&lt;br /&gt;
	local new_args = {}&lt;br /&gt;
	local index = 1&lt;br /&gt;
	&lt;br /&gt;
	for i = 1, #arg_list do&lt;br /&gt;
		local arg = arg_list[i]&lt;br /&gt;
		local value = frame_args[arg]&lt;br /&gt;
		if value == nil then&lt;br /&gt;
			value = frame_args[index]&lt;br /&gt;
			index = index + 1&lt;br /&gt;
		end&lt;br /&gt;
		new_args[arg] = value&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return new_args&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function to handle error messages.&lt;br /&gt;
]]&lt;br /&gt;
function str._error( error_str )&lt;br /&gt;
	local frame = mw.getCurrentFrame()&lt;br /&gt;
	local error_category = frame.args.error_category or 'Errors reported by Module String'&lt;br /&gt;
	local ignore_errors = frame.args.ignore_errors or false&lt;br /&gt;
	local no_category = frame.args.no_category or false&lt;br /&gt;
	&lt;br /&gt;
	if str._getBoolean(ignore_errors) then&lt;br /&gt;
		return ''&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local error_str = '&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;String Module Error: ' .. error_str .. '&amp;lt;/strong&amp;gt;'&lt;br /&gt;
	if error_category ~= '' and not str._getBoolean( no_category ) then&lt;br /&gt;
		error_str = '[[Category:' .. error_category .. ']]' .. error_str&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return error_str&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper Function to interpret boolean strings&lt;br /&gt;
]]&lt;br /&gt;
function str._getBoolean( boolean_str )&lt;br /&gt;
	local boolean_value&lt;br /&gt;
	&lt;br /&gt;
	if type( boolean_str ) == 'string' then&lt;br /&gt;
		boolean_str = boolean_str:lower()&lt;br /&gt;
		if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0'&lt;br /&gt;
				or boolean_str == '' then&lt;br /&gt;
			boolean_value = false&lt;br /&gt;
		else&lt;br /&gt;
			boolean_value = true&lt;br /&gt;
		end&lt;br /&gt;
	elseif type( boolean_str ) == 'boolean' then&lt;br /&gt;
		boolean_value = boolean_str&lt;br /&gt;
	else&lt;br /&gt;
		error( 'No boolean value found' )&lt;br /&gt;
	end&lt;br /&gt;
	return boolean_value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Helper function that escapes all pattern characters so that they will be treated&lt;br /&gt;
as plain text.&lt;br /&gt;
]]&lt;br /&gt;
function str._escapePattern( pattern_str )&lt;br /&gt;
	return mw.ustring.gsub( pattern_str, &amp;quot;([%(%)%.%%%+%-%*%?%[%^%$%]])&amp;quot;, &amp;quot;%%%1&amp;quot; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
count&lt;br /&gt;
This function counts the number of occurrences of one string in another.&lt;br /&gt;
]]&lt;br /&gt;
function str.count(frame)&lt;br /&gt;
	local args = str._getParameters(frame.args, {'source', 'pattern', 'plain'})&lt;br /&gt;
	local source = args.source or ''&lt;br /&gt;
	local pattern = args.pattern or ''&lt;br /&gt;
	local plain = str._getBoolean(args.plain or true)&lt;br /&gt;
	if plain then&lt;br /&gt;
		pattern = str._escapePattern(pattern)&lt;br /&gt;
	end&lt;br /&gt;
	local _, count = mw.ustring.gsub(source, pattern, '')&lt;br /&gt;
	return count&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return str&lt;/div&gt;</summary>
		<author><name>- Hermes -</name></author>	</entry>

	</feed>