我有一個包含幾行像一個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();
感謝。
這可能會有所幫助...請保留逗號前面加雙引號併成功加上雙引號,刪除所有其他逗號 – dannyrosalex
這可能有所幫助:http:// stack overflow.com/questions/5202005/regex-how-to-remove-comma-which-is-between-and – Luftwaffe