How to split a comma separated String while ignoring escaped commas?

后端 未结 4 1366
我寻月下人不归
我寻月下人不归 2020-11-29 03:43

I need to write a extended version of the StringUtils.commaDelimitedListToStringArray function which gets an additional parameter: the escape char.

so calling my:

4条回答
  •  我在风中等你
    2020-11-29 04:09

    Try:

    String array[] = str.split("(?

    Basically this is saying split on a comma, except where that comma is preceded by two backslashes. This is called a negative lookbehind zero-width assertion.

提交回复
热议问题