PeteP Posted September 30, 2008 Share Posted September 30, 2008 Hello, I have one string with several information elements containing spaces or tabs and I would like to pick up all elements... But I just can't really figure out the best way to do it... For example I have $MY_STRING containing following data: "color weight length width" All those are separated with unknown number of spaces or even tabs.. So how can I pick up each of those elements in arrays?? Thanks -Pete Link to comment Share on other sites More sharing options...
Ahmad Posted September 30, 2008 Share Posted September 30, 2008 $information = "bla 2 xD bla ... bla" $information = StringSplit($inforamtion, " ") $information will return an array containing : [0] => 6 (6 items) [1] => "bla" ; first item [2] => "2" ; second item .... ;and so on [6] => "bla" ; until the last one [center]I want to change the world ...., but I don't have the source code xD[/center] Link to comment Share on other sites More sharing options...
martin Posted September 30, 2008 Share Posted September 30, 2008 Hello, I have one string with several information elements containing spaces or tabs and I would like to pick up all elements... But I just can't really figure out the best way to do it... For example I have $MY_STRING containing following data: "color weight length width" All those are separated with unknown number of spaces or even tabs.. So how can I pick up each of those elements in arrays?? Thanks -PeteFirst get rid of the tabs, then convert multiple spaces into one space then stringsplit. $string = "color weight length width" $convert1 = StringReplace($string,Chr(9),'') $convert2 = StringStripWS($convert1,4);strip double (or more) spaces between words $arrayString = StringSplit($convert2,' ') Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
rasim Posted September 30, 2008 Share Posted September 30, 2008 I think this be easy using RegExp: #include <Array.au3> ;Only for _ArrayDisplay :) $MY_STRING = "color weight length width" & @TAB & "test string" $sResult = StringRegExp($MY_STRING, "(\w+)", 3) _ArrayDisplay($sResult) 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