Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string makeModel = csvArray[0]; // or whichever column it is in
- string[] makeAndModel = makeModel.Split( new char[] { ' ' } , 2 );
- string make = makeAndModel[0];
- string model = makeAndModel[1];
- ,(?=([^"]*"[^"]*")*(?![^"]*"))
- 123,456,"Unbalanced quote
- int numFields = 4;
- string[] myFields = myLine.Split(' ');
- int extraSpaces = myFields.length-numFields;
- if(extraSpaces>0) {
- // Piece together element 0 in the array by adding the extra elements
- for(int n = 1; n <= extraSpaces; n++) {
- myFields[0] += ' ' + myFields[n];
- }
- // Move the other values back to elements 1, 2, and 3 of the array
- for(int n = 1; n < numFields; n++) {
- myFields[n] = myFields[n + extraSpaces];
- }
- }
- MatchCollection m = RegEx.Matches(myLine, "^(.*) ([^ ]+) ([^ ]+) ([^ ]+)$");
- string MakeModel = m.Groups[1].Captures[0].ToString();
- string ModelYear = m.Groups[2].Captures[0].ToString();
- string Price = m.Groups[3].Captures[0].ToString();
- string NumWheels = m.Groups[4].Captures[0].ToString();
- string[] myFields = Microsoft.VisualBasic.Replace(myLine.Reverse(), " ", "_", 0, 3).Reverse().Split(' ');
- myFields[0] = myFields[0].Replace("_", " "); //fix the underscores
- String.Split(Convert.ToChar(","));
Add Comment
Please, Sign In to add comment