Function Reference


_StringExplode

Splits up a string into substrings depending on the given delimiters as PHP Explode v5

#include <String.au3>
_StringExplode ( $sString, $sDelimiter [, $iLimit = 0] )

Parameters

$sString String to be split
$sDelimiter Delimiter to split on (split is performed on entire string, not individual characters)
$iLimit [optional] Maximum elements to be returned
    =0 : (default) Split on every instance of the delimiter
    >0 : Split until limit, last element will contain remaining portion of the string
    <0 : Split on every instance, removing limit count from end of the array

Return Value

Returns an array containing the exploded strings.

Remarks

Use negative limit values to remove the first possible elements.

Example

#include <Array.au3>
#include <String.au3>

Local $sText = "one##two##three##four##five##six##seven##eight"
Local $aArray1 = _StringExplode($sText, "##", 0)
_ArrayDisplay($aArray1, "StringExplode 0")

; DISPLAYED
; [0] = one
; [1] = two
; [2] = three
; [3] = four
; [4] = five
; [5] = six
; [6] = seven
; [7] = eight

Local $aArray2 = _StringExplode($sText, "##", 4)
_ArrayDisplay($aArray2, "StringExplode 4")

; DISPLAYED
; [0] = one
; [1] = two
; [2] = three
; [3] = four
; [4] = five##six##seven##eight

Local $aArray3 = _StringExplode($sText, "##", -3)
_ArrayDisplay($aArray3, "StringExplode -3")

; DISPLAYED
; [0] = one
; [1] = two
; [2] = three
; [3] = four
; [4] = five