String Tokenizer : split string by comma and ignore comma in double quotes

后端 未结 6 2047
闹比i
闹比i 2021-01-18 03:58

I have a string like below -

value1, value2, value3, value4, \"value5, 1234\", value6, value7, \"value8\", value9, \"value10, 123.23\"

6条回答
  •  抹茶落季
    2021-01-18 04:43

    You can use several approaches:

    1. Write code that search for comas and maintain a state weather a particular coma is in quotes or note.
    2. Tokenize by double-quote symbol and than tokenize strings in the result array by comma symbol (make sure you tokenize strings with indexes 0, 2, 4, etc., since they were not in double quotes in the original string)

提交回复
热议问题