Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Following is the solution </p> <pre><code>Dim Name As String = "" Dim UserName As String = "" Dim Data As String = """Smith, John J"",jj802b,Shift,5/29/2011,9:30,17:30,5/29/2011,5/29/2011,Transfer" For r As Integer = 1 To 10 Dim DataArr() As String = DecodeCSV(Data) 'Use DecodeCSV function to regex split the string Name = DataArr(0) 'Get First item of array as Name UserName = DataArr(1) 'Get Second item of array as UserName Next </code></pre> <p>Great Code for <a href="http://www.nonhostile.com/howto-decode-csv-regular-expressions-vb-net.asp" rel="nofollow">DecodeCSV by Tim</a></p> <pre><code>Public Shared Function DecodeCSV(ByVal strLine As String) As String() Dim strPattern As String Dim objMatch As Match ' build a pattern strPattern = "^" ' anchor to start of the string strPattern += "(?:""(?&lt;value&gt;(?:""""|[^""\f\r])*)""|(?&lt;value&gt;[^,\f\r""]*))" strPattern += "(?:,(?:[ \t]*""(?&lt;value&gt;(?:""""|[^""\f\r])*)""|(?&lt;value&gt;[^,\f\r""]*)))*" strPattern += "$" ' anchor to the end of the string ' get the match objMatch = Regex.Match(strLine, strPattern) ' if RegEx match was ok If objMatch.Success Then Dim objGroup As Group = objMatch.Groups("value") Dim intCount As Integer = objGroup.Captures.Count Dim arrOutput(intCount - 1) As String ' transfer data to array For i As Integer = 0 To intCount - 1 Dim objCapture As Capture = objGroup.Captures.Item(i) arrOutput(i) = objCapture.Value ' replace double-escaped quotes arrOutput(i) = arrOutput(i).Replace("""""", """") Next ' return the array Return arrOutput Else Throw New ApplicationException("Bad CSV line: " &amp; strLine) End If End Function </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload