fork download
  1. Imports System.Text.RegularExpressions
  2.  
  3. Module Module1
  4. Private r As Regex = New Regex( _
  5. "^N(?:;(?!CHARSET=UTF-8)[^:]*|)(?:;CHARSET=UTF-8|):(?<strSurname>[^;\n\r]*);?(?<strGivenName>[^;\n\r]*);?(?<strMidName>[^;\n\r]*);?(?<strPrefix>[^;\n\r]*);?(?<strSuffix>[^;\n\r]*)", _
  6. RegexOptions.IgnoreCase Or RegexOptions.Multiline)
  7. Sub Main()
  8. Dim s As String = "BEGIN:VCARD" + System.Environment.NewLine + _
  9. "VERSION:2.1" + System.Environment.NewLine + _
  10. "N:Bacon;Kevin" + System.Environment.NewLine + _
  11. "FN: Kevin Bacon" + System.Environment.NewLine + _
  12. "ORG:Movies.com"
  13. Dim m As Match = r.Match(s)
  14. If (m.Success) Then
  15. Console.WriteLine(m.Groups("strSurname").Value)
  16. Console.WriteLine(m.Groups("strGivenName").Value)
  17. Console.WriteLine(m.Groups("strMidName").Value)
  18. Console.WriteLine(m.Groups("strPrefix").Value)
  19. Console.WriteLine(m.Groups("strSuffix").Value)
  20. End If
  21. End Sub
  22. End Module
Success #stdin #stdout 0.09s 18920KB
stdin
Standard input is empty
stdout
Bacon
Kevin