Originally posted by newbieBrian
[code=java]
field= field.toString( ).replaceAll("[\t"], ",");
[/code]
If a field can contain a comma by itself your rules become a bit more complicated.
You have to use several passes:
1) replace ", +" by something unique (say XXX) and no white spaces in it;
2) replace "[ \t]{3,} by ", ", i.e. at least three spaces or tabs by a comma and a space;
3) if you find [^ ]XXX[^ ], replace it by the same with "s around it.
4) replace XXX back by a ", "
maybe you should use one of the freely available CSV processing packages.
kind regards,
Jos
Comment