Originally Richard helped me with the first portion of my problem which was parsing the richtextbox data.
here is the code:
Dim rows() As String = Regex.Split(RichTextBox1.Text, "^\r?$", RegexOptions.Multiline)
Dim pattern As New Regex("^\s*(?<label>[^:]+)\s*:\s*(?<value>.+)\s*\r?$", RegexOptions.Multiline)
For Each row As String In rows
Dim lastName As String = Nothing, firstName As String = Nothing, race As String = Nothing, sex As String = Nothing
Dim matches As MatchCollection = pattern.Matches(row)
For Each match As Match In matches
Dim label As String = match.Groups("label").Value
If String.Equals(label, "last Name", StringComparison.OrdinalIgnoreCase) Then
lastName = match.Groups("value").Value
ElseIf String.Equals(label, "First Name", StringComparison.OrdinalIgnoreCase) Then
firstName = match.Groups("value").Value
ElseIf String.Equals(label, "Race", StringComparison.OrdinalIgnoreCase) Then
race = match.Groups("value").Value
ElseIf String.Equals(label, "Sex", StringComparison.OrdinalIgnoreCase) Then
End If
Next
I have been trying to work on the 2nd portion of my problem. Now to make the process skip over a value if it is not present.
so let's say I have -
First Name: jeff
last Name: jones
Race: B
First Name: steve
last Name: need
First Name: lance
Sex: M
Race: W
you can see in these examples have other fields that others do not. I want to skip over the information that is not present, possibly even put a blank string "" in just to move the process along.
What I have tried:
I have tried the value =
Match.Empty.Value
I have tried to use the skip command, but I just keep getting a null reference error.