Jump to content

Recommended Posts

Posted

$oReEn = ":Param1:Param2:Param3:Param4:Param5:Param6:NewParam1:NewParam2:NewParam3:NewParam4:NewParam5:NewParam6:NewParam7"; Etc.
$oReEn = StringSplit($oReEn, ":")
For $i = 1 To $oReEn[0]
    ConsoleWrite($oReEn[$i] & ":")
Next

That would output the whole line of params.

But I want each section, seperate;

Param1:Param2:Param3:Param4:Param5:Param6

NewParam1:NewParam2:NewParam3:NewParam4:NewParam5:NewParam6

Everything ive tried has failed.

Anyone have any ideas?

Basically, I have a dynamic string. Its got information in it that I would need.

But its all in one line. Each set of 6, would start out with new information.

That most likely didnt make sense. But I dont know how to explain it clearer.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Posted

$oReEn = ":Param1:Param2:Param3:Param4:Param5:Param6:NewParam1:NewParam2:NewParam3:NewParam4:NewParam5:NewParam6:NewParam7"
While 1
    $x = ""
    $oReEnx = StringSplit($oReEn, ":")
    For $i = 2 To 7
        $x &= $oReEnx[$i] & ":"
    Next
    $oReEn = StringReplace($oReEn, $x, "")
    ConsoleWrite($x & @CRLF)
WEnd

I put that together.

But at the last line, Theres nothing left to use, So it errors out?

I cant figure out a way to exitloop before the error.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Posted (edited)

Before trying to access some array element, always make sure that it exists to begin with, to avoid error. What is so hard to understand about this concept? I.e., before trying to read elements 2 to 7 in a For loop, make sure array has 8 elements, and if it doesn't, either exit the outer loop, or skip the reading.

Anyway, here's another way:

$oReEn = ":Param1:Param2:Param3:Param4:Param5:Param6:NewParam1:NewParam2:NewParam3:NewParam4:NewParam5:NewParam6:NewParam7"

$a = StringRegExp($oReEn, '((?i::[^:]+){6})', 3)

If Not @error Then
    For $e In $a
        ConsoleWrite($e & @CRLF)
    Next
EndIf
Edited by Siao

"be smart, drink your wine"

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
×
×
  • Create New...