public class Main {
public static void main(String[] args) {
String line = "foo,bar,c;qual=\"baz,blurb\",d;junk=\"quux,syzygy\"";
String[] tokens = line.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1);
for(String t : tokens) {
System.out.println("> "+t);
}
}
}
If you do this,
Output result:
> foo
> bar
> c;qual="baz,blurb"
> d;junk="quux,syzygy"
It comes out like this.
© 2024 OneMinuteCode. All rights reserved.