import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "([\\,]?)(.*?),(.*?),(.*?),([^,\\n]+)";
final String string = "-5,1270516,36,4511997,-5,12376876,36,44785827,-5,12316936,36,44645229,-5,12098128,36,44464959,-5,11927452,36,44249823,-5,11787448,36,44130483,-5,11503048,36,43988193,-5,11298136,36,43932321,-5,11051788,36,43890813,-5,1062994,36,43792524,-5,1073704,36,44205732,-5,1092262,36,4427127,-5,10928704,36,4449573,-5,11439868,36,44664156,-5,11416072,36,4494348,-5,12014428,36,45678996,-5,12379684,36,45426204,-5,1270516,36,4511997\n"
+ "-5,2373088,36,4018572,-5,24624112,36,40067244,-5,2491384,36,39872772,-5,25086388,36,39455001,-5,2521966,36,39240261,-5,2551792,36,39058875,-5,25849336,36,38917395,-5,25736728,36,38870469,-5,25593844,36,3882411,-5,25539412,36,38690235,-5,2515756,36,38599326,-5,24923452,36,38546505,-5,24732616,36,38415195,-5,2461486,36,38364264,-5,2444962,36,38420514,-5,24023056,36,38179152,-5,23217088,36,39022551,-5,2373088,36,4018572";
final String subst = "$1$2.$3 $4.$5";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
// The substituted value will be contained in the result variable
final String result = matcher.replaceAll(subst);
System.out.println("Substitution result: " + result);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html