1

Topic: Auto it to deduce substrings from a line.

 $elem_1 = StringSplit ("1 2 3 4", "", 1)
MsgBox (4096, "we Return an amount of elements:", $elem_1 [0]) 

I Want, that the amount of elements four was deduced, and deduces six.
Here help, like on it would do.
[spoiler] StringSplit
Divides a line into substrings, depending on the given separator.
StringSplit ("string", "delimiters" [flag = 0])
Parameters
string the Used line.
delimiters One or more characters are used as a separator (match case).
flag [optional] Change of a method of sharing, can be a combination of following values:
0 - (by default), each character in a separator of a line is a separator.
1 - all line of a separator is a separator.
2 - to disconnect resetting of an amount of elements in the first array cell (it is necessary to use UBound () to receive the size of an array).
Returned value
Returns an array in which by default the first element $aArray [0] contains an amount of the returned lines, remaining elements ($aArray [1], $aArray [2], etc.) contain the partitioned lines. If flag = 2 in the first element the amount of elements is not returned, and the first element of the partitioned line is returned.
If the separator in a required line is not found, @error = 1, the amount in $aArray [0 =1 and is returned all line in $aArray [1].
Remarks
If you use blank line as a separator "" each character will be returned in an array cell.
If you want to use substring as a separator instead of as single characters, look an example more low.
StringSplit () it is very useful as alternative StringInStr () and as means of filling of an array.
The warning if you in a separator use  - @CRLF 2 line characters which generate additional empty elements in an array are actually used.
See also
StringRegExp, StringToASCIIArray, StringMid, StringInStr
Example
#include <Array.au3>
$aDays = StringSplit ("Vs, Pn, W, Sr, Cht, Pt, a Sat" ",")
; $aDays [1] contains "Vs"... $aDays [7] contains "Sat"
_ArrayDisplay ($aDays, ' Days of week '); function for review of arrays
$sText = "Eta\nStroka\nSoderzhit\nPerenos \n style of Si."
$aArray = StringSplit ($sText, '\n ', 1)
_ArrayDisplay ($aArray, ' Analysis of a line ')
For $i = 1 To $aArray [0]; the Cycle shows all values element-wise.
MsgBox (4096, "the Example 2", "$aArray [" and $i and "] =" and $aArray [$i])
Next
[/spoiler]
P. S.
Only through StringRegExpReplace at first to process?

2

Re: Auto it to deduce substrings from a line.

3

Re: Auto it to deduce substrings from a line.

Roma35
For space suppression there is a special function StringStripWS

$elem_1 = StringSplit (StringStripWS ("1 2 3 4", 4), "", 1)
MsgBox (4096, "we Return an amount of elements:", $elem_1 [0])

And so glance on http://autoit-script.ru/index.php?action=forum
There always help

FUKS :
There is such feature?

For example

#include <Array.au3>
$rep = _StringSplitRegExp ("1 2 3 4", '\h {1,} ', 0)
_ArrayDisplay ($rep)
Func _StringSplitRegExp ($sString, $sPattern, $sIncludeMatch = false, $iCount = 0)
Local $sReservedPattern = Chr (0)
Local $sReplacePattern = $sReservedPattern
If $sIncludeMatch Then $sReplacePattern = "$0" AND $sReplacePattern
$sTemp = StringRegExpReplace ($sString, $sPattern, $sReplacePattern, $iCount)
If StringRight ($sTemp, 1) = $sReservedPattern Then $sTemp = StringTrimRight ($sTemp, 1)
$aResult = StringSplit ($sTemp, $sReservedPattern, 1)
Return $aResult
EndFunc; ==> _StringSplitRegExp

4

Re: Auto it to deduce substrings from a line.

Works.