I want to convert a tab delimited text file to a XML file. I was able to do it with a single character delimiter. But how do i extend it to tabs? I am coding in C# and using Visual Studio 2010.
+1
A:
A tab is a single character, written as '\t'
. Try adapting your existing solution to use that. If that doesn't work, post more details about your approach and the problems you encountered.
Blair Conrad
2010-05-27 10:58:38
+1
A:
Basically you want to split your lines using the tab char? In that case, use the method you already have and use \t
for splitting.
riffnl
2010-05-27 11:05:59
See answer by Blair Conrad :-) -- beat me to it
riffnl
2010-05-27 11:07:11
+1
A:
Are the tabs an \t
symbol? Then the task is, basically, the same.
If by tabs you mean multiple spaces, you might want to delete the extra spaces. A simple way is to use a regex:
string input = "This is text with far too much " +
"whitespace.";
string pattern = "\\s+";
string replacement = " ";
Regex rgx = new Regex(pattern);
string result = rgx.Replace(input, replacement);
mcm69
2010-05-27 12:47:15