Hello. I searched the NUG archives for any code pertaining to RegEx
and CSV (Comma Separated Values).
I came upon this formula from 2004: (?<=,)("[^"]*"|'[^']*'|[^,]*)(?=,)
Of course, when I set the search pattern to the above, I double-quote
the quotation marks.
When I feed the data into the RegEx search, I prepend and append
commas to the data.
The search works, but only returns the first value.
For testing, I used an example from WikiPedia:
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""",,4900.00
1996,Jeep,Grand Cherokee,"MUST SELL!
air, moon roof, loaded",4799.00
For each of these values, I only receive back, 1997, 1999, 1996, and
air.
My routine looks like this:
reo.Greedy = true
re.Options = reo
re.SearchPattern = "(?<=,)(""[^""]*""|'[^']*'|[^,]*)(?=,)1)"
match = re.search("," + sDataLine + ",")
If match <> Nil then
iMax = match.SubExpressionCount-1
for iLoop = 1 to iMax
asReturn.Append match.SubExpressionString(iLoop)
next
End if
What am I doing wrong?
Thanks for the help,
Christian
Pariahware, Inc. Custom Software
<[EMAIL PROTECTED]>
<http://www.pariahware.com>
--
God loved you so much that He gave His only son Jesus. What have you
done with God's gift?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>