<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://wicri-demo.istex.fr/Wicri/Europe/ChansonRoland/fr/index.php?action=history&amp;feed=atom&amp;title=Module%3AString%2FDocumentation</id>
	<title>Module:String/Documentation - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://wicri-demo.istex.fr/Wicri/Europe/ChansonRoland/fr/index.php?action=history&amp;feed=atom&amp;title=Module%3AString%2FDocumentation"/>
	<link rel="alternate" type="text/html" href="https://wicri-demo.istex.fr/Wicri/Europe/ChansonRoland/fr/index.php?title=Module:String/Documentation&amp;action=history"/>
	<updated>2026-04-19T07:03:26Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.31.10</generator>
	<entry>
		<id>https://wicri-demo.istex.fr/Wicri/Europe/ChansonRoland/fr/index.php?title=Module:String/Documentation&amp;diff=41397&amp;oldid=prev</id>
		<title>imported&gt;Jacques Ducloy : Jacques Ducloy a déplacé la page String/Documentation vers Module:String/Documentation</title>
		<link rel="alternate" type="text/html" href="https://wicri-demo.istex.fr/Wicri/Europe/ChansonRoland/fr/index.php?title=Module:String/Documentation&amp;diff=41397&amp;oldid=prev"/>
		<updated>2023-04-16T06:02:07Z</updated>

		<summary type="html">&lt;p&gt;Jacques Ducloy a déplacé la page &lt;a href=&quot;/Wicri/Europe/ChansonRoland/fr/index.php?title=String/Documentation&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;String/Documentation (page inexistante)&quot;&gt;String/Documentation&lt;/a&gt; vers &lt;a href=&quot;/Wicri/Europe/ChansonRoland/fr/index.php/Module:String/Documentation&quot; title=&quot;Module:String/Documentation&quot;&gt;Module:String/Documentation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Le module String (un mot [[anglais]] signifiant ''chaîne de caractères'') permet de manipuler des chaînes de caractères.&lt;br /&gt;
&lt;br /&gt;
== Utilisation ==&lt;br /&gt;
&lt;br /&gt;
Fonctions exportables :&lt;br /&gt;
* &amp;lt;code&amp;gt;len&amp;lt;/code&amp;gt; – renvoie le nombre de caractères dans une chaîne, prend en compte les caractères multi-octets (''len'' ou ''length'' signifie ''taille'', ''longueur'')&lt;br /&gt;
* &amp;lt;code&amp;gt;sub&amp;lt;/code&amp;gt; – renvoie une partie de la chaîne de caractères (''sub'' ou ''sub-string'' signifie ''sous-chaîne'')&lt;br /&gt;
&lt;br /&gt;
Autres fonctions : &amp;lt;br/&amp;gt;&lt;br /&gt;
À compléter…&lt;br /&gt;
&lt;br /&gt;
Modules externes et autres éléments dont ce module a besoin pour fonctionner : &amp;lt;br/&amp;gt;&lt;br /&gt;
À compléter…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== len ===&lt;br /&gt;
Cette fonction renvoie la longueur de la chaîne de caractère cible.&lt;br /&gt;
&lt;br /&gt;
;Fonctionnement :&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|len|chaîne_de_caractère_cible}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
OU&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|len|s=chaîne_de_caractère_cible}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Paramètres :&lt;br /&gt;
*&amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; : la chaîne de caractère dont la longueur doit être signalée&lt;br /&gt;
&lt;br /&gt;
S'il est appelé à l'aide de paramètres nommés, MediaWiki supprimera automatiquement tout espace blanc de début ou de fin de la chaîne de caractère cible.&lt;br /&gt;
&lt;br /&gt;
=== sub ===&lt;br /&gt;
Cette fonction renvoie une sous-chaîne de caractère spécifiée par des indices numériques d'une chaîne cible.&lt;br /&gt;
&lt;br /&gt;
;Fonctionnement :&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|sub|chaîne_de_caractère_cible|index_de_départ|index_de_fin}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
OU&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|sub|s=chaîne_de_caractère_cible|i=index_de_départ|j=index_de_fin}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Paramètres :&lt;br /&gt;
*&amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt; : la chaîne de caractère de départ&lt;br /&gt;
*&amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; : le début de la sous-chaîne de caractère commence à l'entier indiqué par ce paramètre, par défaut à 1.&lt;br /&gt;
*&amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt; : la fin de la sous-chaîne de caractère finit à l'entier indiqué par ce paramètre.&lt;br /&gt;
 &lt;br /&gt;
Le premier caractère de la chaîne se voit attribuer un index de 1. Si &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; ou &amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt; est une valeur négative, cela est interprété comme la sélection d'un caractère en comptant à rebours à partir de la fin de la chaîne de caractère cible. Par conséquent, une valeur de -1 revient à sélectionner le dernier caractère de la chaîne.&lt;br /&gt;
&lt;br /&gt;
Si les indices demandés sont hors limites pour la chaîne donnée, une erreur est signalée. Si un paramètre d'index est omis, la chaîne de caractère cible est reprise à l'identique, au commencement ou à la fin suivant l'omission et le signe du paramètre restant.&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;
&amp;lt;pre&amp;gt;{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|match|s=source_string|pattern=pattern_string|start=start_index&lt;br /&gt;
    |match=match_number|plain=plain_flag|nomatch=nomatch_output}}&amp;lt;/pre&amp;gt;&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 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 string. This specifies which match to return, where the first match is match= 1. If a negative number is specified then a match is returned counting from the last match. Hence match = -1 is the same as requesting the last match. Defaults to 1.&lt;br /&gt;
*plain: A flag indicating that the pattern should be understood as plain 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;
=== 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;
&amp;lt;pre&amp;gt;{{#invoke:String|pos|target_string|index_value}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|pos|target=target_string|pos=index_value}}&amp;lt;/pre&amp;gt;&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;
=== 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;
&amp;lt;pre&amp;gt;{{#invoke:String|find|source_str|target_string|start_index|plain_flag}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}}&amp;lt;/pre&amp;gt;&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 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;
&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;
&amp;lt;pre&amp;gt;{{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|replace|source=source_string|pattern=pattern_string|replace=replace_string|&lt;br /&gt;
   count=replacement_count|plain=plain_flag}}&amp;lt;/pre&amp;gt;&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 text and not as a Lua style regular expression, defaults to true &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== rep ===&lt;br /&gt;
&lt;br /&gt;
Cette fonction répète la même chaîne de multiple fois.&lt;br /&gt;
&lt;br /&gt;
Utilisation :&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|rep|texte|nombre}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paramètres :&lt;br /&gt;
* texte : le texte à répeter&lt;br /&gt;
* nombre : le nombre de répétition&lt;br /&gt;
&lt;br /&gt;
=== count ===&lt;br /&gt;
Cette fonction compte le nombre de fois qu'un motif apparaît dans la chaîne de caractère. &lt;br /&gt;
&lt;br /&gt;
Utilisation :&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|count|texte|motif|plain_flag}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paramètres :&lt;br /&gt;
* texte : la chaîne de caracère&lt;br /&gt;
* motif: le motif (ou ''pattern'') a rechercher&lt;br /&gt;
* plain_flag: Indicateur booléen indiquant que le modèle doit être compris comme du texte brut et non comme une expression régulière de style Lua compatible Unicode; la valeur par défaut est ''true''&lt;br /&gt;
&lt;br /&gt;
== Exemples ==&lt;br /&gt;
&lt;br /&gt;
===len===&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|len|ABCDEFGHIJ}}&amp;lt;/pre&amp;gt;           renvoie {{#invoke:String|len|ABCDEFGHIJ}}     &lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|len|É}} &amp;lt;/pre&amp;gt;                   renvoie {{#invoke:String|len|É}}, même si É occupe 2 octets&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:String|len| }}  &amp;lt;/pre&amp;gt;                  renvoie {{#invoke:String|len| }}  , les espaces blancs sont pris en compte&lt;br /&gt;
&lt;br /&gt;
===sub===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{#invoke:String|sub|ABCDEFGHIJ|0}}        renvoie une erreur, ici l'index commence à 1 (contrairement à d'autres langages de programmation)&lt;br /&gt;
{{#invoke:String|sub|ABCDEFGHIJ|5}}        renvoie EFGHIJ, on commence à partir du 5ème caractère et on prend le reste&lt;br /&gt;
{{#invoke:String|sub|ABCDEFGHIJ|1|3}}      renvoie ABC, on commence à partir du 1er jusqu'au 3ème&lt;br /&gt;
{{#invoke:String|sub|ABCDEFGHIJ|1|1}}      renvoie A&lt;br /&gt;
{{#invoke:String|sub|ABCDEFGHIJ|-1}}       renvoie J, l'index est inversé on commence à la fin&lt;br /&gt;
{{#invoke:String|sub|ABCDEFGHIJ|-5|-2}}    renvoie FGHI&lt;br /&gt;
{{#invoke:String|sub|ABCDEFGHIJ|-5|2}}     renvoie une erreur, l'index de fin doit être après l'index de début (2 est placé avant -5) &lt;br /&gt;
{{#invoke:String|sub|ABCDEFGHIJ|-5|7}}     renvoie FGHI, l'index de fin est bien après l'index de début&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===count===&lt;br /&gt;
&lt;br /&gt;
Exemples:&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;###{#invoke:String|count|aabbcc|a}}###&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; : ###{{#invoke:String|count|aabbcc|a}}### --nombre de a&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;###{#invoke:String|count|aabbcc|z}}###&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; : ###{{#invoke:String|count|aabbcc|z}}### --nombre de z&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;###{#invoke:String|count|aabbcc|[ac]|plain=false}}###&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; : ###{{#invoke:String|count|aabbcc|[ac]|plain=false}}### --nombre de a ou de c&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;###{#invoke:String|count|11-aa-2587|[0-9]|plain=false}}###&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; : ###{{#invoke:String|count|11-aa-2587|[0-9]|plain=false}}### --nombre de chiffres&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;###{#invoke:String|count|Il était une fois| |plain=true}}###&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; : ###{{#invoke:String|count|Il était une fois| |plain=true}}### --nombre de blancs&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;###{#invoke:String|count|Il était une fois|[ ]|plain=false}}###&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; : ###{{#invoke:String|count|Il était une fois|[ ]|plain=false}}### --nombre de blancs&lt;br /&gt;
&lt;br /&gt;
== Voir aussi ==&lt;br /&gt;
* [[:Catégorie:Modèle de manipulation de chaîne]]&lt;br /&gt;
&lt;br /&gt;
{{Traduction/Référence|en|Module:String/doc}}&lt;br /&gt;
&lt;br /&gt;
{{Projet Scribunto}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
[[Catégorie:Module en langage Lua]]&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Jacques Ducloy</name></author>
		
	</entry>
</feed>