Skip to content

Instantly share code, notes, and snippets.

@cnmoro
Created August 5, 2019 18:01
Show Gist options
  • Save cnmoro/22cdcd2456c00aaa309a2e4df57a3ecc to your computer and use it in GitHub Desktop.
Save cnmoro/22cdcd2456c00aaa309a2e4df57a3ecc to your computer and use it in GitHub Desktop.
Java split csv correctly
String text = "age: 28,favorite number: 26,\"salary: $1,234,108\"";
String[] strArray = text.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
for (String s : strArray) {
s = s.replaceAll("\"", "");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment