January 16th, 2012, 02:37 PM
Can someone tell me if there is already a funciton for this?
Hey there people,
I have a file in this format:-
FIRST_VALUE, This is a value
SECOND_VALUE, This is another value
THIRD_VALUE, This is also a value
I use a function to read this data into an array which ends up like this:-
first_array(0) = "FIRST_VALUE, This is a value"
first_array(1) = "SECOND_VALUE, This is another value"
How the heck do I take that array an split it down the middle so that I have something like this:-
first_array(0) = "FIRST_VALUE"
second_array(0) = "This is a value"
January 20th, 2012, 03:35 AM
To me that sounds like a problem for the RegEx-Namespace (regular Expressions). Although I am currently not too familiar with that this sounds as if you just need to search for the x-th occurence of a sequence of letters, starting with a capital one and terminated by a "," and put each into the (x-1)-th position inside your array.
Maybe you can also work with string.IndexAt(string s) to search for the "," and "\n" symbols and cut of, what you don't need with string.trim().
At least the first option will work fine, although it might be a little bit more complicated than using the options of the string-class.
January 21st, 2012, 04:08 PM
Thank you for your reply, I'll report back on how I solved this one when I do.
February 14th, 2012, 03:18 PM
Read You file usinf .ReadLine() then on the returning string call string.split(",") you will get an array with two elements with each of the elements.