Datta Kharad

Datta Kharad

  • NA
  • 1.6k
  • 53.4k

Big issue in split operation

Dec 20 2011 10:05 AM
Hi
  //This is normal input line which is read from csv file and i want to get value only comma separator (i,e Redhighlighted comma only)
Note:- I cant modify that line example:- remove double quote or add double quote in line

  str="12,Goods,"LCD,HDD",V21,HIGH",xyz,pqr,vbc";       //Input line          
 
 //I tried this code..I have separated in string array (named as arr) using comma(,) separator.
 string[] arr= str.Split(','); 

//After split value:- Actual array                      
arr[12]
arr[Goods]
arr["LCD]
arr[HDD"]
arr[V21]
arr[HIGH"]
arr[xyz]
arr[pqr]
arr[vbc]

//After split value:- Expected array                      
arr[12]
arr[Goods]
arr["LCD,HDD",V21,HIGH"]
arr[xyz]
arr[pqr]
arr[vbc] 
 
 
 //--------
 ----------


 //Output
 // 12     Goods    "LCD,HDD",V21,HIGH"    xyz    pqr      vbc


//If it will open in Excel file then it is displaying properly as like above output, but i want that output  either in string variable or string array  using c# code , so give me appropriate solution for doing that output.
Thanks in advance.

Answers (7)