sshrum Posted August 4, 2012 Share Posted August 4, 2012 Given: "test|foo|bar;test2|bar|foo;Test3|boo|far" ...is there a quick way to split the sting into a multi-dim array? Split 1 on ";" Split 2 on "|" yielding: [test][foo][bar] [test2][bar][foo] [test2][boo][far] If not, is there a easy way to do this...I'm getting ready to just write a function but I usually tend to over think these things and 9 outta 10 times someone points me in the right direction. TIA Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Link to comment Share on other sites More sharing options...
water Posted August 4, 2012 Share Posted August 4, 2012 Search the forum for "stringsplit array" and select "Only search in titles" and you will find a lot of hits. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
sshrum Posted August 4, 2012 Author Share Posted August 4, 2012 Yes, because stringsplit deals with SINGLE dimensioned arrays so, over course there will be a TON of hits...but basically it's finding a needle in the outback for 1 or 2 dealing with MULTI dimensioned arrays. Following your suggestion however, I haven't found anything that looks like what I was after...I do see a ton of ppl doing what I was going to do which was to code the multi dim array with a loop of my own but that doesn't answer the question: Does a function exist to take a string with 2 delimiters to create a multi-dim array? You might as well have sed to look at every forum post and eventually I'll find it. Sometimes the direct approach is faster and easier...you sir, are the contradiction to that statement. Sry, it's late and I know you're just trying to empower me... :-S Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Link to comment Share on other sites More sharing options...
water Posted August 4, 2012 Share Posted August 4, 2012 Yes, because stringsplit deals with SINGLE dimensioned arrays so, over course there will be a TON of hits...but basically it's finding a needle in the outback for 1 or 2 dealing with MULTI dimensioned arrays.On the first page you'll find what you need. I tried the search myself but was too lazy to copy the links.Does a function exist to take a string with 2 delimiters to create a multi-dim array?No.You might as well have sed to look at every forum post and eventually I'll find it. Sometimes the direct approach is faster and easier...you sir, are the contradiction to that statement.This is the old "Give a man a fish or teach him how to fish" discussion.Here is a fish: My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
sshrum Posted August 4, 2012 Author Share Posted August 4, 2012 I saw that fish (er, post). I figured someone woulda put a multi delimiter function together like StringSplit2d($String, ";", "|"). The one here uses @LF as the first delimiter. Guess I'll just write one for myself. Thx. Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Link to comment Share on other sites More sharing options...
sshrum Posted August 4, 2012 Author Share Posted August 4, 2012 P.S. did you read my sig? Teach a man to fish...hehe. Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Link to comment Share on other sites More sharing options...
water Posted August 4, 2012 Share Posted August 4, 2012 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
czardas Posted August 4, 2012 Share Posted August 4, 2012 (edited) Taken from my CSVSplit function. Slight modification to code. I think you should try and turn this into a proper function along with error checks. Your idea BTW. #include <Array.au3> Dim $sString = "test|foo|bar;test2|bar|foo;Test3|boo|far" Dim $asDelim[2] = [";","|"] $iOverride = 0 $aArray = StringSplit($sString, $asDelim[0], 2) ; Split to get rows $iBound = UBound($aArray) Dim $aReturn[$iBound][2], $aTemp For $i = 0 To $iBound -1 $aTemp = StringSplit($aArray[$i], $asDelim[1]) ; Split to get row items If Not @error Then If $aTemp[0] > $iOverride Then $iOverride = $aTemp[0] ReDim $aReturn[$iBound][$iOverride] ; Add columns to accomodate more items EndIf EndIf For $j = 1 To $aTemp[0] If StringLen($aTemp[$j]) Then $aReturn[$i][$j -1] = $aTemp[$j] ; Populate each row EndIf Next Next _ArrayDisplay($aReturn) Edited August 4, 2012 by czardas operator64 ArrayWorkshop 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