Aide:StringSplit.txt

De Wiki AutoIt Français
Aller à : navigation, rechercher

Document original V3.3.6.1 :

###Function###
StringSplit

###Description###
Splits up a string into substrings depending on the given delimiters.

###Syntax###
StringSplit ( "string", "delimiters" [, flag ] )


###Parameters###
@@ParamTable@@
string
	The string to evaluate.
delimiters
	One or more characters to use as delimiters (case sensitive).
flag
	[optional] Changes how the string split works, add mutliple flag values together if required:
	  flag = 0 (default), each character in the delimiter string will mark where to split the string
	  flag = 1, entire delimiter string is needed to mark the split
	  flag = 2, disable the return the count in the first element - effectively makes the array 0-based (must use UBound() to get the size in this case).
@@End@@


###ReturnValue###
Returns an array, by default the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) contain the delimited strings.  If flag = 2 then the count is not return in the first element.

If no delimiters were found @error is set to 1, the count is 1 ($array[0]) and the full string is returned ($array[1]).


###Remarks###
If you use a blank string "" for the delimiters, each character will be returned as an element.

If the delimiter you wish to use is a substring instead of individual single characters, see the example below.

StringSplit is very useful as an alternative to StringInStr and as a means to populate an array.

Caution if you use the macro @CRLF you are referring to a 2 character string so you will generate extra blanks lines.


###Related###
StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper


###Example###
@@IncludeExample@@


Document traduit V3.3.6.1 :

###Function###
StringSplit

###Description###
Sépare une chaîne en sous-chaînes selon les délimiteurs donnés.


###Syntax###
StringSplit ( "string", "delimiters" [, flag ] )


###Parameters###
@@ParamTable@@
string
	La chaîne à évaluer.
delimiters
	Un ou plusieurs caractères à utiliser comme délimiteurs (sensible à la casse).
flag
	[optionnel] Change le fonctionnement de la séparation de chaîne. Additionnez les valeurs d'options si nécessaire :
	  flag = 0 (par défaut), chaque caractère dans la chaîne de délimitation marquera la séparation de la chaîne
	  flag = 1, la chaîne de délimitation entière est nécessaire pour marquer la séparation
	  flag = 2, désactive le comptage du nombre d'éléments dans l'élément 0 - Retourne un tableau de base 0 (vous devrez utiliser UBound() pour en récupérer la taille).
@@End@@


###ReturnValue###
Retourne un tableau, par défaut le premier élément ($array[0]) contient le nombre de chaînes retournées, les éléments qui restent ($array[1], $array[2], etc.) contiennent les chaînes délimitées.  Si flag = 2 alors le comptage n'est pas retourné dans le premier élément.

Si aucun délimiteur n'est trouvé, @error est mis à 1, le compte est 1 ($array[0]) et la chaîne complète est retournée ($array[1]).


###Remarks###
Si vous utilisez une chaîne vide "" en tant que délimiteur, chaque caractère sera retourné comme un élément.

Si le délimiteur que vous souhaitez utiliser est une sous-chaîne au lieu d'un simple caractère, voir l'exemple ci-dessous.

StringSplit est une très bonne alternative à StringInStr et comme moyen de remplissage d'un tableau.

Attention si vous utilisez la macro @CRLF, car vous faîtes référence à une chaine de 2 caractères donc des lignes vides supplémentaires seront créées.


###Related###
<a href="StringInStr.htm">StringInStr</a>, <a href="StringLeft.htm">StringLeft</a>, <a href="StringLen.htm">StringLen</a>, <a href="StringLower.htm">StringLower</a>, <a href="StringMid.htm">StringMid</a>, <a href="StringRight.htm">StringRight</a>, <a href="StringTrimLeft.htm">StringTrimLeft</a>, <a href="StringTrimRight.htm">StringTrimRight</a>, <a href="StringUpper.htm">StringUpper</a>


###Example###
@@IncludeExample@@


Traducteur : Alex74

Contributeurs (pour les modifications avant le Wiki) : Tlem