fork download
  1. Imports System
  2. Imports System.Collections.Generic
  3.  
  4. Public Class Test
  5. shared function mysplit(s as string) as List(of string)
  6. dim arr as string() = s.Split(",")
  7. dim list as List(of string) = new List(of string)
  8. dim b as boolean = false
  9. dim buf as string
  10. for each i as string in arr
  11. if b then
  12. if i.endswith(chr(34)) then
  13. list.add(buf & "," & i)
  14. buf = ""
  15. b = false
  16. else
  17. buf = buf & "," & i
  18. end if
  19. else
  20. if i.startswith(chr(34)) then
  21. if i.endswith(chr(34)) then
  22. list.add(i)
  23. else
  24. buf = i
  25. b = true
  26. end if
  27. else
  28. list.add(i)
  29. end if
  30. end if
  31. next
  32. return list
  33. end function
  34.  
  35. Public Shared Sub Main()
  36. ' your code goes here
  37. dim s as string = """aaa"",""ddd"",""eee,eee,eee,"",""rrr"",123,"""""
  38. dim r as List(of string) = mysplit(s)
  39. for each s as string in r
  40. Console.WriteLine(s)
  41. next
  42. End Sub
  43. End Class
Success #stdin #stdout 0.07s 24536KB
stdin
Standard input is empty
stdout
"aaa"
"ddd"
"eee,eee,eee,"
"rrr"
123
""