我有一个 CSV 文件,其中包含如下几行:
"bar","foo, bar","18","07/09/2012 02:08:16","payments, recent","payments, all"
一些值包含逗号,我需要删除这些逗号才能获得这个结果:
"bar","foo bar","18","07/09/2012 02:08:16","payments recent","payments all"
我从这个正则表达式开始,"^(\".+\"\\,?)+$"
但它对我来说太复杂了。
最终目标是拆分该字符串:
string content = reader.ReadToEnd();
string[] lignes = contenu.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
for (int i = 1; i < lignes.Length; i++)
{
// REMOVE COMMAS
string[] values = csv.Split(new[] {','});
// do something
}
reader.Close();
谢谢。