Function Reference


_StringBetween

Find strings between two string delimiters

#include <String.au3>
_StringBetween ( $sString, $sStart, $sEnd [, $iMode = $STR_ENDISSTART [, $bCase = False]] )

Parameters

$sString The string to search.
$sStart The beginning of the string to find. Passing an empty string starts at the beginning
$sEnd The end of the string to find. Passing an empty string searches from $sStart to end of string
$iMode [optional] Search mode when $sStart = $sEnd
$STR_ENDISSTART (0) the $sEnd string at the end of a match starts the next possible match (default)
$STR_ENDNOTSTART (1) a further instance of the $sStart starts the next match
$bCase [optional] False (default setting) = case-insensitive. True = case-sensitive.

Return Value

Success: a 0-based array - element [0] contains the first found string.
Failure: sets the @error flag to non-zero.
@error: 1 - No strings found.

Example

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

Example()

Func Example()
        ; Create an array of all the values between "[" and "]".
        Local $aArray = _StringBetween("[18][20][3][5][500][60]", "[", "]")

        ; Display the results in _ArrayDisplay.
        _ArrayDisplay($aArray, "Default Search")

        ; Create an array of all the values between "|" and "|" - note $sStart and $sEnd are identical
        Local $sString = "-----|Both Modes|$STR_ENDISSTART only|Both Modes|-----"

        ; Mode $STR_ENDISSTART - default - $sEnd is next $sStart
        $aArray = _StringBetween($sString, "|", "|")
        ; Display the results in _ArrayDisplay.
        _ArrayDisplay($aArray, "$STR_ENDISSTART")

        ; Mode $STR_ENDNOTSTART - $sEnd is not next $sStart
        $aArray = _StringBetween($sString, "|", "|", $STR_ENDNOTSTART)
        ; Display the results in _ArrayDisplay.
        _ArrayDisplay($aArray, "$STR_ENDNOTSTART")
EndFunc   ;==>Example