Sub ParseDate(Input As String) As Map
Dim rMap As Map
rMap.Initialize
rMap.Put("Day", "")
rMap.Put("Month", "")
rMap.Put("Year", "")
' Split into tokens on spaces
Dim tokens() As String = Regex.Split(" +", Input.Trim)
' Lower-case list of month names/abbrevs
Dim monthNames As List
monthNames.Initialize
monthNames.AddAll(Array As String( _
"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec", _
"january","february","march","april","may","june","july","august","september","october","november","december" _
))
For Each t As String In tokens
Dim lc As String = t.ToLowerCase
' 1–2 digit day?
If Regex.IsMatch("^[0-9]{1,2}$", lc) Then
rMap.Put("Day", t)
' 4-digit year?
Else If Regex.IsMatch("^[0-9]{4}$", lc) Then
rMap.Put("Year", t)
' month name/abbr?
Else If monthNames.IndexOf(lc) > -1 Then
rMap.Put("Month", t)
End If
Next
Return rMap
End Sub