madmasles
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Skif_off, Пример: Код: #include <Array.au3> Local $sStr, $aStr, $sDelim, $iCount = 10, $sTmpStr, $aDelim[3] = [@CRLF, @CR, @LF], $iRand = Random(0, 2, 1) For $i = 1 To Random(50, 100, 1) $sStr &= $i & $aDelim[$iRand] Next Select Case StringInStr($sStr, @CRLF) $sDelim = @CRLF ConsoleWrite('$sDelim = @CRLF' & @LF) Case StringInStr($sStr, @CR) $sDelim = @CR ConsoleWrite('$sDelim = @CR' & @LF) Case StringInStr($sStr, @LF) $sDelim = @LF ConsoleWrite('$sDelim = @LF' & @LF) Case Else Exit 13 EndSelect ;~ 1 variant: ;~ a: $sTmpStr = StringLeft($sStr, StringInStr($sStr, $sDelim, 0, $iCount) - 1) $aStr = StringSplit($sTmpStr, $sDelim, 1) _ArrayDisplay($aStr, '1.a') ;~ b: $aStr = StringSplit($sTmpStr, $sDelim, 3) _ArrayDisplay($aStr, '1.b') ;~ 2 variant: ;~ a: $aStr = StringSplit($sStr, $sDelim, 1) If $aStr[0] > $iCount Then ReDim $aStr[$iCount + 1] $aStr[0] = $iCount EndIf _ArrayDisplay($aStr, '2.a') ;~ b: $aStr = StringSplit($sStr, $sDelim, 3) If UBound($aStr) > $iCount Then ReDim $aStr[$iCount] EndIf _ArrayDisplay($aStr, '2.b') |
|