Created
August 5, 2019 18:01
-
-
Save cnmoro/22cdcd2456c00aaa309a2e4df57a3ecc to your computer and use it in GitHub Desktop.
Java split csv correctly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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