Jump to content
Sign in to follow this  
randallc

_StringSplit without ubound in [0], faster?

Recommended Posts

randallc

Hi,

There is a thread in "request forum", showing that an option for "StringSplit" without the extra count element at the beginning is "not going to happen"

I have thought about how to get it faster, given that _ArrayDelete($ar,0) is so slow;

Here is my second suggestion!

OMG! wot wos i thinking...

Func _StringSplit2($sStr, $sSepF, $iFlag = 0)
    Local $sTmp = $sStr, $arFileF[1] = [$sStr], $iPos, $iPos1, $sLenSep = StringLen($sSepF), $iCaseSens = 1
    If $sSepF = "" Then ;handle empty splitter separator
        $iPos = 2
        $sTmp = StringLeft($sStr, 1)
        ; if Sep has more than 1 character, we must first check for ;split the Separator into individual characters
    ElseIf Not $iFlag And $sLenSep > 1 Then ;maybe we should use RegExp
        ; check the first character as separator, to find likely $iPos candidate
        Local $aSep = StringSplit($sSepF, "", 1) ;split the Separator into individual characters
        $iPos = StringInStr($sTmp, $aSep[1], $iCaseSens)
        $sTmp = StringLeft($sTmp, $iPos - 1) ;keep as short as possible
        For $c = 2 To UBound($aSep) - 1; loop through the rest of the separators in case any are sooner
            $iPos1 = StringInStr($sTmp, $aSep[$c ], $iCaseSens)
            If $iPos1 And $iPos1 < $iPos Then ;must be found, and < $iPos
                $iPos = $iPos1
                $sTmp = StringLeft($sTmp, $iPos - 1) ;keep as short as possible
            EndIf
        Next
    Else ;if $iFlag=1 or only 1 character, above not needed
        If $sLenSep > 1 Then $iCaseSens = 0 ;stringsplit is NOT case-sensitive if more than 1 char in separator, used as 1
        $iPos = StringInStr($sStr, $sSepF, $iCaseSens)
        $sTmp = StringLeft($sStr, $iPos - 1)
    EndIf
    If Not $iPos Then Return SetError(@error, 0, $arFileF)
    If Not $iFlag And $sLenSep Then $sLenSep = 1 ;change length for single char separators of "0" $iFlag
    $sStr = StringMid($sStr, $iPos + $sLenSep)
    $arFileF = StringSplit($sStr, $sSepF, $iFlag)
    $arFileF[0] = $sTmp
    Return SetError(0, 0, $arFileF);$arFileF
EndFunc   ;==>_StringSplit2

Modified due to:

1. Bug for 2 elements.

2. Case anomaly in "StringSplit"

3. Case of more than 1 character in Separator not handled except by group

4. Empty separator not handled accurately.

Any feedback welcome asap, as the func in last beta was buggy...

Thanks, Randall

Edited by randallc

Share this post


Link to post
Share on other sites
Thatsgreat2345

Hi,

There is a thread in "request forum", showing that an option for "StringSplit" without the extra count element at the beginning is "not going to happen"

I have thought about how to get it faster, given that _ArrayDelete($ar,0) is so slow;

Here is my first suggestion, using RegExp (about 3x as fast as inbuilt), but it needs fixing;

$sStr = $sSepF & $sStr & $sSepF
$sPattern = "(?=[^|" & $sSepF & "])([^" & $sSepF & "]*)(?=" & $sSepF & ")"
$arFileF = StringRegExp($sStr, $sPattern, 3)oÝ÷ ÛSh¶·­®'¯x©äzW¦z{ljÚkzǧ·c^yÛn)b·+h¥«,é®)íx,¦X­r«iË^®À'Ê¥¦è¶«²è zËb¢{¢·Ú²×«jk¡§!Â¥u·¦Þr&­yÝ÷ë-E©ÝjYZºÚ"µÍÈÝ[ÔÜ]]LÂÚ[ÛYIØ^K]LÉÝÂßÐ]]Ò]ÕÜÕÙP[ÚO^BÌÍÜÔÙH  ][ÝË  ][ÝÂßØØ[   ÌÍÜÑ[HH[SÜ[X[ÙÊ  ][ÝÉ][ÝËØÜ    ][ÝÊ

I][ÝÊK    ÌÍÜÑ[XYHÝ[ÔXÙJ[TXY
    ÌÍÜÑ[JKÔ   ][ÝË  ][ÝÊBßØØ[  ÌÍØ[HHÝ[ÔÜ]
    ÌÍÜÑ[XY ][ÝË  ][ÝÊK ÌÍØÈHÐ^Q[]J    ÌÍØ[K
BßØØ[    ÌÍØ[HHÝ[ÔÜ]
    ÌÍÜÑ[XYÔJK ÌÍØÈHÐ^Q[]J    ÌÍØ[K
BØØ[  ÌÍÜÑ[XYH    ][ÝØKËKËKKËKËKKËKËKKËKËXKËKËKKËKËI][ÝÂÌÍØ[HHÔÝ[ÔÜ]J  ÌÍÜÑ[XY ÌÍÜÔÙ
BßÐ^QÜ^J ÌÍØ[K    ][ÝÉÌÍØ[I][ÝÊBÏOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOBÌÍØ[LHHÔÝ[ÔÜ]
    ÌÍÜÑ[XY ÌÍÜÔÙ
BßÐ^QÜ^J ÌÍØ[LK   ][ÝÉÌÍØ[LI][ÝÊBÏOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOB[ÈÔÝ[ÔÜ]
    ÌÍÜÔÝ  ÌÍÜÔÙ  ÌÍÚS[HHL
NÈ ][ÝÉ[ÉÌÍÜÔÙ [É][ÝÂSØØ[ ÌÍÜÕ[YH[Y[]

BQÜ    ÌÍÚHHÈ  ÌÍÚS[BBSØØ[    ÌÍØ[QHÝ[ÔÜ]
    ÌÍÜÔÝ  ÌÍÜÔÙJK    ÌÍØÈHÐ^Q[]J    ÌÍØ[Q
BS^PÛÛÛÛUÜ]J   ][ÝÝ[YLI][ÝÈ    [ÈÝ[
[YY ÌÍÜÕ[YKH    [ÈBPÛÛÛÛUÜ]J  ][ÝÕPÝ[
    ÌÍØ[QOI][ÝÈ    [ÈPÝ[
    ÌÍØ[QH   [ÈBPÛÛÛÛUÜ]J  ][ÝÉÌÍØ[QÌOI][ÝÈ    [È ÌÍØ[QÌH [ÈBPÛÛÛÛUÜ]J  ][ÝÉÌÍØ[QÕPÝ[
    ÌÍØ[QKLWOI][ÝÈ [È ÌÍØ[QÕPÝ[
    ÌÍØ[QHHWH    [ÈBT]  ÌÍØ[Q[[ÈÏOIÝ×ÔÝ[ÔÜ][ÈÔÝ[ÔÜ]J    ÌÍÜÔÝ  ÌÍÜÔÙ  ÌÍÚS[HHL
NÈ ][ÝÉ[ÉÌÍÜÔÙ [É][ÝÂSØØ[ ÌÍÜÕ[YH[Y[]

BSØØ[ ÌÍÜÔ]H  ][ÝÊÏV× ][ÝÈ  [È ÌÍÜÔÙ  [È ][Ý×JJ×][ÝÈ    [È ÌÍÜÔÙ  [È ][Ý×JJÏI][ÝÈ   [È ÌÍÜÔÙ  [È ][ÝÊI][ÝÂPÛÛÛÛUÜ]J ][ÝÉÌÍÜÔ]I][ÝÈ  [È ÌÍÜÔ]   [ÈBIÌÍÜÔÝH    ÌÍÜÔÙ  [È ÌÍÜÔÝ  [È ÌÍÜÔÙQÜ   ÌÍÚHHÈ  ÌÍÚS[BBIÌÍØ[QHÝ[ÔYÑ^
    ÌÍÜÔÝ  ÌÍÜÔ]ÊBS^PÛÛÛÛUÜ]J    ][ÝÝ[YLI][ÝÈ    [ÈÝ[
[YY ÌÍÜÕ[YKH    [ÈBPÛÛÛÛUÜ]J  ][ÝÕPÝ[
    ÌÍØ[QOI][ÝÈ    [ÈPÝ[
    ÌÍØ[QH   [ÈBPÛÛÛÛUÜ]J  ][ÝÉÌÍØ[QÌOI][ÝÈ    [È ÌÍØ[QÌH [ÈBPÛÛÛÛUÜ]J  ][ÝÉÌÍØ[QÕPÝ[
    ÌÍØ[QKLWOI][ÝÈ [È ÌÍØ[QÕPÝ[
    ÌÍØ[QHHWH    [ÈBT]  ÌÍØ[Q[[ÈÏOIÝ×ÔÝ[ÔÜ]
Hmmm looks good. I may give it a try I use stringsplit alot. ( wow quote and edit just mess up everything wtf)

Share this post


Link to post
Share on other sites
BrettF

Hmmm... using this string:

Local $sFileread = "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|" _ 
& "StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah"

The results are:

$sPattern=(?=[^|,])([^,]*)(?=,)

time2=30.16

UBound($arFileF)=1

$arFileF[0]=StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBl

ahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBla

hBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Stri

ngBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBla

hBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlah

Blah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|

StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Strin

gBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlah

BlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahB

lah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|S

tringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|String

BlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahB

lahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBl

ah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|St

ringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringB

lahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBl

ahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBla

h|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Str

ingBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBl

ahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBla

hBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Stri

ngBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBla

hBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

$arFileF[uBound($arFileF)-1]=StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|St

ringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringB

lahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBl

ahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBla

h|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Str

ingBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBl

ahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBla

hBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Stri

ngBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBla

hBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlah

Blah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|

StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Strin

gBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlah

BlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahB

lah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|S

tringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|String

BlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahB

lahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBl

ah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|St

ringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringB

lahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBl

ahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBla

h|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Str

ingBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

time2=12.73

UBound($arFileF)=1

$arFileF[0]=StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBl

ahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBla

hBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Stri

ngBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBla

hBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlah

Blah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|

StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Strin

gBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlah

BlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahB

lah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|S

tringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|String

BlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahB

lahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBl

ah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|St

ringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringB

lahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBl

ahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBla

h|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Str

ingBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBl

ahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBla

hBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Stri

ngBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBla

hBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

$arFileF[uBound($arFileF)-1]=StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|St

ringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringB

lahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBl

ahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBla

h|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Str

ingBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBl

ahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBla

hBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Stri

ngBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBla

hBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlah

Blah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|

StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Strin

gBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlah

BlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahB

lah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|S

tringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|String

BlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahB

lahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBl

ah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|St

ringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringB

lahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBl

ahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBla

h|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|Str

ingBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah|StringBlahBlahBlah

Is that good?? :D

Share this post


Link to post
Share on other sites
randallc

Hmmm... using this string:

Hi,

Not sure how to answer that!

I asked for either

1. Help to fix the Regexp

or

2. An alternative suggestion to speed up StringSplit;

Is this under (1.) because it shows (what I already knew) that the regexp needs fixing still (especially for non-alphabetical split characters etc...)?

Best, randall

PS - I guess you could say (1.) also because it shows that splits with very large elements may be slower with RegExp; but not for small elements, or "real life" tests with splitting lines of files, for instance, when I have tested...

Edited by randallc

Share this post


Link to post
Share on other sites
randallc

Hi,

OMG! wot wos i thinking...

Func _StringSplit($sStr, $sSepF, $iFlag=0)
    Local $iPos = StringInStr($sStr, $sSepF), $sTmp = StringLeft($sStr, $iPos - 1)
    $sStr = StringMid($sStr, $iPos + StringLen($sSepF))
    Local $arFileF = StringSplit($sStr, $sSepF, $iFlag)
    $arFileF[0] = $sTmp
    Return $arFileF
EndFunc   ;==>_StringSplit
Edited by randallc

Share this post


Link to post
Share on other sites
BrettF

Hi,

OMG! wot wos i thinking...

Func _StringSplit($sStr, $sSepF, $iFlag=0)
    Local $iPos = StringInStr($sStr, $sSepF), $sTmp = StringLeft($sStr, $iPos - 1)
    $sStr = StringMid($sStr, $iPos + StringLen($sSepF))
    Local $arFileF = StringSplit($sStr, $sSepF, $iFlag)
    $arFileF[0] = $sTmp
    Return $arFileF
EndFunc   ;==>_StringSplit
Who knows... :P Looks good! :D

Share this post


Link to post
Share on other sites
Thatsgreat2345

I kinda prefer it starting at 1 :D, since I'm so used to just doing for $i = 1 to Ubound($array) - 1 :P.

Share this post


Link to post
Share on other sites
randallc

Hi,

Testing if possible? - post #1 has new protype, about 4x faster on decent size stringsplit than using ArrayDelete.

Modified due to:

1. Bug for 2 elements.

2. Case anomaly in "StringSplit"

3. Case of more than 1 character in Separator not handled except by group

4. Empty separator not handled accurately.

Any feedback welcome asap, as the func in last beta was buggy...

Thanks, Randall

[PS inbuilt StringSplit found, on testing, to be Case-Sensitive, but not on multiple character separator (when flag=1, "treat as group, not individual chars"); is this deliberate, do you think!?]

Edited by randallc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×