hi,
I need some help with a reg. expression. I have a comma delimited file with
quotes. Not every field has quotes, only some. This is a sample of my file:
99,"01/01/2007","23,000", 1,34,"henry",13 2,"45.00"
I used some code from an article that I though would do what I needed, but
it splits my amount fields(76,000 into two different fields : 76, and 000...
Do I change my pattern ? I never used regex before and need some help. thank
you.
I need some help with a reg. expression. I have a comma delimited file with
quotes. Not every field has quotes, only some. This is a sample of my file:
99,"01/01/2007","23,000", 1,34,"henry",13 2,"45.00"
I used some code from an article that I though would do what I needed, but
it splits my amount fields(76,000 into two different fields : 76, and 000...
Do I change my pattern ? I never used regex before and need some help. thank
you.
Code:
Dim re As Object = SplitAdv(sr.ReadToEnd) Function SplitAdv(ByVal strInput) Dim objRE Dim pattern As String pattern = ",(?=([^']*'[^']*')*(?![^']*'))" objRE = New Regex(pattern) ' .Replace replaces the comma that we will use with ' chr(8), the \b character which is extremely unlikely ' to appear in any string it then splits the line into ' an array based on the \b 'Console.WriteLine(objRE.ToString) SplitAdv = Split(objRE.Replace(strInput, "\b"), "\b") End Function
Comment