I have a data array with multiple rows that I'm trying to output to a `CSV` file. The input file has a different amount of blank spaces between columns so the columns don't match up with the cells in the excel spreadsheet. When I write,
output.WriteLine(s.Replace(" ", ","));
it takes away all blank spaces and replace them with commas making the csv file look terrible. I was wondering if there was a way I could loop through get rid of all the blank spaces and replace them with only one comma instead of many.
Any help would be great.
You need to make use of regular expressions
以上就是Trying to replace a different amount of spaces with only one comma的详细内容，更多请关注web前端其它相关文章！