I have a text file that is tab-delimited. How can I separate this string into substrings for an array by detecting the tabs?
A:
Just use the String.Split
method and split on tabs (so probably first one split on newlines to get the lines and then one on tabs to get the values).
See here for details:
http://msdn.microsoft.com/en-us/library/system.string.split.aspx
ho1
2010-05-09 12:54:06
thanks, CD. I didn't realize split would take escape sequences like this.
Jimmy
2010-05-09 13:09:18
A:
If you use String.split() you can split the String around any regular expression, including tabs. The regex that matches tabs is \t, so you could use the following example;
String foo = "Hello\tWorld";
String[] bar = foo.split("\t");
Which would return a String array containing the words Hello and World
Jivings
2010-05-09 13:00:57