Reputation: 3
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.
Upvotes: 0
Views: 765
Reputation: 730
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);
Upvotes: 1
Reputation: 3183
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.
Upvotes: 1
Reputation: 241714
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.
Upvotes: 1