Two things: One, I had to tweak this from what I currently use, data in quotes instead of pipes. Also, you didn't just post someones arrest record up? If the data is not clean, I would ask the moderator to clean it up or Pedro might be mad. <g>
' Imports System.Text.RegularExpressions
' Regular expression built for Visual Basic on: Sat, Jan 13, 2007, 01:15:45 PM
' Using Expresso Version: 3.0.2559, http://www.ultrapico.com
'
' Will put columns into named capture groups. Data found in pipes, but pipes not included in capture.
'
' A description of the regular expression:
'
' Match a prefix but exclude it from the capture. [,|^]
' Select from 2 alternatives
' ,
' Beginning of line or string
' Match expression but don't capture it. [\|], zero or one repetitions
' Literal |
' [Column]: A named capture group. [[^\|]*]
' Any character that is NOT in this class: [\|], any number of repetitions
' Match expression but don't capture it. [\|], zero or one repetitions
' Literal |
' Match a suffix but exclude it from the capture. [,|$]
' Select from 2 alternatives
' ,
' End of line or string
'
'
Public Dim CSV as Regex = New Regex( _
"(?<=,|^)(?:\|)?(?<Column>[^\|]*)(?:\|)?(?=,|$)", _
RegexOptions.Singleline _
Or RegexOptions.ExplicitCapture _
Or RegexOptions.CultureInvariant _
Or RegexOptions.Compiled _
)