How to split items in a string separated by “,”

后端 未结 6 1423
栀梦
栀梦 2021-01-03 02:33

In my App, data comes in String like this

\"Hi,Hello,Bye\"

I want to separate data by \",\"

How can I do that?

6条回答
  •  天命终不由人
    2021-01-03 03:13

    Well, the naïve approach would be to use componentsSeparatedByString:, as suggested in the other answers.

    However, if your data is truly in the CSV format, you'd do well to consider using a proper CSV parser, such as this one (which I wrote): https://github.com/davedelong/CHCSVParser

提交回复
热议问题