Click here to Skip to main content
15,881,715 members
Home / Discussions / C#
   

C#

 
QuestionChars received Pin
Tichaona J22-Oct-10 10:26
Tichaona J22-Oct-10 10:26 
AnswerRe: Chars received Pin
dbrenth22-Oct-10 10:49
dbrenth22-Oct-10 10:49 
GeneralRe: Chars received Pin
Tichaona J22-Oct-10 11:11
Tichaona J22-Oct-10 11:11 
AnswerRe: Chars received [modified] Pin
Pete O'Hanlon22-Oct-10 11:54
mvePete O'Hanlon22-Oct-10 11:54 
AnswerRe: Chars received [modified] Pin
Luc Pattyn22-Oct-10 15:23
sitebuilderLuc Pattyn22-Oct-10 15:23 
QuestionParsing csv file with commas and quotes as deliminators Pin
roman_s22-Oct-10 9:00
roman_s22-Oct-10 9:00 
AnswerRe: Parsing csv file with commas and quotes as deliminators Pin
fjdiewornncalwe22-Oct-10 10:35
professionalfjdiewornncalwe22-Oct-10 10:35 
AnswerRe: Parsing csv file with commas and quotes as deliminators [Modified] Pin
OriginalGriff22-Oct-10 10:40
mveOriginalGriff22-Oct-10 10:40 
Please do not use this solution - the FileHelper one is much better and easier to use / understand.


You can't do that easily with string.Split - it only works on a single character. You will either have to do it manually or use a regex:
string inputText = @"1530,Pasadena CA,""2008, 05/01"",""2005, 12/14""";
Regex regex = new Regex("(?=,)|[^\",]+|\"(?:[^\"]|\"\")*\"",
                        RegexOptions.Compiled);
MatchCollection ms = regex.Matches(inputText);
foreach (Match m in ms)
    {
    if (m.Length > 0)
        {
        Console.WriteLine(m.Value);
        }
    }
The regex looks ugly, but it was thrown together a bit quickly - that's why it generates blank matches.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

AnswerRe: Parsing csv file with commas and quotes as deliminators Pin
Luc Pattyn22-Oct-10 15:25
sitebuilderLuc Pattyn22-Oct-10 15:25 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
PIEBALDconsult22-Oct-10 16:42
mvePIEBALDconsult22-Oct-10 16:42 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
Luc Pattyn22-Oct-10 16:43
sitebuilderLuc Pattyn22-Oct-10 16:43 
AnswerRe: Parsing csv file with commas and quotes as deliminators Pin
Brady Kelly22-Oct-10 19:23
Brady Kelly22-Oct-10 19:23 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
OriginalGriff22-Oct-10 22:21
mveOriginalGriff22-Oct-10 22:21 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
PIEBALDconsult15-Dec-10 7:40
mvePIEBALDconsult15-Dec-10 7:40 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
Brady Kelly15-Dec-10 19:39
Brady Kelly15-Dec-10 19:39 
AnswerRe: Parsing csv file with commas and quotes as deliminators Pin
OriginalGriff22-Oct-10 23:39
mveOriginalGriff22-Oct-10 23:39 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
Luc Pattyn23-Oct-10 2:45
sitebuilderLuc Pattyn23-Oct-10 2:45 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
OriginalGriff23-Oct-10 3:43
mveOriginalGriff23-Oct-10 3:43 
QuestionClose Pop Up windows Pin
SatyaKeerthi1522-Oct-10 3:11
SatyaKeerthi1522-Oct-10 3:11 
AnswerRe: Close Pop Up windows Pin
Not Active22-Oct-10 3:22
mentorNot Active22-Oct-10 3:22 
QuestionAnnoying ListBox problem [SOLVED] Pin
Henry Minute22-Oct-10 3:10
Henry Minute22-Oct-10 3:10 
AnswerRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 4:35
sitebuilderLuc Pattyn22-Oct-10 4:35 
GeneralRe: Annoying ListBox problem Pin
OriginalGriff22-Oct-10 4:42
mveOriginalGriff22-Oct-10 4:42 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:16
sitebuilderLuc Pattyn22-Oct-10 5:16 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 4:46
Henry Minute22-Oct-10 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.