I've got text in a file as such:
VMMAnalogs_Acquire.c 1.26 2001_105/02 2001_105/02
Analogs_Acquire 100% 100%
VMMAnalogs_Initialise.c 1.25 2001_053/02 2001_053/02
Analogs_InitialiseInput 100% 100%
I want to write this data to a csv file, thus need to replace certain white space sections with a comma, as such:
VMMAnalogs_Acquire.c,1.26,2001_105/02,2001_105/02
Analogs_Acquire,100%
VMMAnalogs_Initialise.c,1.25,2001_053/02,2001_053/02
Analogs_InitialiseInput,100%
Here is code that replaces all white spaces with to get started:
string input = listTxtFileContents[line_idx];
string pattern = "\\s+";
string replacement = ",";
Regex rgx = new Regex(pattern);
string result = rgx.Replace(input, replacement);
listTxtFileContents[line_idx] = result;
Can anyone help me please?
The problem that I'm facing is that the code replaces all the spaces with a single comma. I don't want it to replace the indentation of the 2nd and the 4th line's, words. (Analogs_Acquire and Analogs_InitialiseInput)
P.S. please vote up/down!