Leykis101 Posted October 15, 2008 Share Posted October 15, 2008 I need to split a string that might look something like this: sectionone _three spaces_ section two _Ten spaces_ this is is section three _five spaces_ sectionfour Sorry about the way I had to write that, the board was cleaning extra spaces out of my sentence. Does anybody know a good way to achieve this? Thanks! Link to comment Share on other sites More sharing options...
Andreik Posted October 15, 2008 Share Posted October 15, 2008 I need to split a string that might look something like this: sectionone _three spaces_ section two _Ten spaces_ this is is section three _five spaces_ sectionfour Sorry about the way I had to write that, the board was cleaning extra spaces out of my sentence. Does anybody know a good way to achieve this? Thanks! Try this: $TEXT should be "sectionone _three spaces_ section two _Ten spaces_ this is is section three _five spaces_ sectionfour" $StripWS = StringStripWS($TEXT,4) $DATA = StringSplit($StripWS," ") Link to comment Share on other sites More sharing options...
andybiochem Posted October 15, 2008 Share Posted October 15, 2008 (edited) #include <array.au3> $string = "section one section two this is is section three section four" $string = StringRegExpReplace($string,"\h{3,}","¬") $array = StringSplit($string,"¬") _ArrayDisplay($array) Edited October 15, 2008 by andybiochem - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! Link to comment Share on other sites More sharing options...
Leykis101 Posted October 15, 2008 Author Share Posted October 15, 2008 Thanks a TON guys! Fast reply! Now I will have to sit down and try to break down and understand what yours is doing andybiochem Link to comment Share on other sites More sharing options...
andybiochem Posted October 15, 2008 Share Posted October 15, 2008 Thanks a TON guys! Fast reply! Now I will have to sit down and try to break down and understand what yours is doing andybiochem Here's an explanation: ;----- this include allows us to view the array we're creating #include <array.au3> ;----- this is the string we want to test $string = "section one section two this is is section three section four" ;----- in Regular Expressions "\h{3,}" means... "a horizontal whitespace, 3 times or more" ;----- each time a match for this is found it is replaced with "¬" $string = StringRegExpReplace($string,"\h{3,}","¬") ;----- now split the string wherever there is a "¬" $array = StringSplit($string,"¬") ;----- display the array _ArrayDisplay($array) Xandy 1 - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! 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