I wrote a parser that reads a file line by line and parses it with a regex statement. (Regex below)
case "countries":
pattern = "\\\"(.+?)\\\"(\\s+)?(\\((.+?)\\))?(\\s+)?(\\{(.+?)\\(\\#(.+?)\\)\\})?(\\s+)?(.+)";
substitution = "$1, $4, $7, $8, $10";
break;
This outputs a list with all the groups I want and each group separated by a comma. (through the result.split(",");) Now lets say I don't want to use a comma but instead an | or an *. Changing the comma to any other string doesn't seem to change anything. What am I missing?
try (CSVWriter csvWriter = new CSVWriter(new FileWriter(myLocalPath + "CSV/" + choice.toLowerCase() + ".csv")))
{
Pattern r = Pattern.compile(pattern);
while (br.readLine() != null)
{
String nextLine = br.readLine();
Matcher matcher = r.matcher(nextLine);
String result = matcher.replaceAll(substitution);
String[] line = result.split("lorem");
csvWriter.writeNext(line, false);
}
}catch(Exception e){
System.out.println(e);
System.out.println("Parsing done!");
}