Regex expression in java remove first value in csv -
I have a CSV file that looks like this:
12,2014- 10 - 09 06: 00: 00,2014-10-09 06:15:00, "", "", "", "123,456", "", "9,999", "", "" < / Pre> string test = rowData.replaceAll ("([0- 9]), ([0-0] 9])," $ 1 $ 2 " I'm not sure that this is the best way to do this (the opinion is my problem is to remove the first value before commas. Needed, so basically my output should be something like this Orig: 12,2014-10-09 06:00: 00-10-10 06:15:00, "", "", "", "123456,", "", "9,999", "", "" requirement: 2014-10-09 06: 00: 00,2014-10-09 06:15:00, ,, 123456, 99 99, I'm not sure that doing this requires another regex because I do not know how OK Or use something like last time or the first index to remove the fist value of a comma? Thanks
Edit: I saw that I can not use ([0- 9]), ( [0- 9]) The reason it also removes a comma for the timetable: (.) The correct question is how to replace the CSV: 1. First value 2. Quotation 3. Between the digits and quotes Cama
your expectations You can do something like this to match the output of the output
string str = "12,2014-10-09 06: 00: 00,2014-10- 09" + "06: 15:00, \ "\", \ "\", \ "123,456 \", \ "\", \ "9,999 \", \ "\", \ "\" str = str.substring (str.indexOf ( ',') + 1); Str = str.replaceAll ("\" (\\ d +), (\\ d +) \ "", "$ 1 $ 2") .replace ("\", ""); string expected = "2014 -10-09 06: 00: 00,2014-10-09 06:15:00 ,,,, 123456, 9999, "; System Output." / html>
Comments
Post a Comment