replace - Java Replacing all commas with semi-colons except the ones inside quotations marks -
replacing commas except ones inside quotations marks in java csv style user input.
i've done research can't wrap head around how/where start this, not sure if can ask questions without adding code but, if me suggesting functions use/research appreciate it
p.s i've seen few other posts read wasn't working properly.
2 suggestions:
- use csv parsing library commons-csv tokenize input , re-join whichever character want. csv libraries smart enough not split on commas within quotes.
- implement finite state machine (2 states: within quotes , outside quotes) scan input keeping track of whether or not current character inside quotes. when find comma , you're not inside quotes, replace it.
Comments
Post a Comment