import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(.*?),(.*?),'(.*?),'(.*?),'(.*?),'(.*?),(.*)";
final String string = "2016/11/09,12:10:00,'4355,'4358,'4346,'4351,1,201\n"
+ "2016/11/09,12:09:00,'4361,'4362,'4353,'4355,1,117\n"
+ "2016/11/09,12:08:00,'4364,'4374,'4359,'4360,10,175\n"
+ "2016/11/09,12:07:00,'4371,'4376,'4360,'4365,590\n"
+ "2016/11/09,12:06:00,'4359,'4372,'4358,'4369,420\n"
+ "2016/11/09,12:05:00,'4365,'4367,'4356,'4359,542\n"
+ "2016/11/09,12:04:00,'4379,'1380,'4360,'4365,1,697\n"
+ "2016/11/09,12:03:00,'4394,'4396,'4376,'4381,1,272\n"
+ "2016/11/09,12:02:00,'4391,'4399,'4390,'4393,524";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
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