ParoXsitiC Posted September 13, 2007 Share Posted September 13, 2007 (edited) In 2006 this code use to work fine: $sParamStr = "$testarray, $sub2," $asParams = StringRegExp($sParamStr, '([^ ]*?[ ]?,)*', 3) It would return this: $asParams[0] = "$testarray," $asParams[1] = "$sub2," Now the latest stable, it returns this: $asParams[0] = "$testarray," $asParams[1] = "" --------------------- Can anyone explain to me what changed and what is going on? Edited September 13, 2007 by ParoXsitiC Link to comment Share on other sites More sharing options...
ParoXsitiC Posted September 13, 2007 Author Share Posted September 13, 2007 (edited) I changed the * to + and it works fine. $asParams = StringRegExp($sParamStr, '([^ ]*?[ ]?,)*', 3) No work $asParams = StringRegExp($sParamStr, '([^ ]*?[ ]?,)+', 3) Works I found out the blank element is a NULL char. Edited September 13, 2007 by ParoXsitiC Link to comment Share on other sites More sharing options...
ParoXsitiC Posted September 13, 2007 Author Share Posted September 13, 2007 Bump. I am really curious what's going on here. Link to comment Share on other sites More sharing options...
Xenobiologist Posted September 13, 2007 Share Posted September 13, 2007 Hi, what do you want? #include<Array.au3> $sParamStr = "$testarray, $sub2," $asParams = StringRegExp($sParamStr, '\$.*?(?=,| )', 3) _ArrayDisplay($asParams) So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
ParoXsitiC Posted September 13, 2007 Author Share Posted September 13, 2007 Hi, what do you want? #include<Array.au3> $sParamStr = "$testarray, $sub2," $asParams = StringRegExp($sParamStr, '\$.*?(?=,| )', 3) _ArrayDisplay($asParams) So long, Mega This is fine but the reason why he did it in such a weird way is because there is also support for Literals and not just params. Therefore a string may look like this: $test, Function("test 2") The $ is needed in the extracted so do that you can tell if its a parameter or a literal. Here is his complete code to get a better understand whats going on: If $sParamStr <> "" Then If StringRight($sParamStr, 1) <> "," Then $sParamStr &= ","; Makes $sParamStr easier to parse with StringRegExp EndIf $asParams = StringRegExp($sParamStr, '(".*?".*?,|[^ ]*?[ ]?,)*', 3) If Not IsArray($asParams) Then SetError(2); Parameter string not formatted correctly Return -1; failure EndIf For $i = 0 To UBound($asParams) - 1 If StringInStr($asParams[$i], "$") Then $sStrippedParam = StringReplace(StringReplace($asParams[$i], "$", ""), ",", "") If IsDeclared($sStrippedParam) Then $vParamEval = Eval($sStrippedParam) $sPackedParamStr &= _PackVarToStr($vParamEval) Else $sParamLiteral = StringTrimRight($asParams[$i], 1) $sPackedParamStr &= _PackVarToStr($sParamLiteral) EndIf Else $sParamLiteral = StringTrimRight($asParams[$i], 1) $sPackedParamStr &= _PackVarToStr($sParamLiteral) EndIf Next Link to comment Share on other sites More sharing options...
ParoXsitiC Posted September 14, 2007 Author Share Posted September 14, 2007 Okay I am just going to assume that the + is the way it should be done and include it into the released UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now