I have the following String :
XYZ,132917057937901,150617,051244,+12.345555,+73.179481,0,153,45,11,1,3,000,00,0.0,9.23,7.40,24.74,0.0,0,0.90,0,0,345,1374,108
Now i want to extract value at the 16th position 9.23
and 17th position 7.40
.
This string is fixed with their position.
How can i get value at 16th and 17th position ?
答案 0 :(得分:4)
Use String.split
instead of regex:
String[] split = input.split(',');
String pos16 = split[15];
In case you do want to use regex, match using this and get groups 1 and 2:
Matcher m = Pattern.compile("(?:[^,]*,){15}([^,]*),([^,]*)").matcher(input);
m.find();
String pos16 = m.group(1);