Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuart-marks/9729226fcc03e4eedfc5e7f282566e60 to your computer and use it in GitHub Desktop.
Save stuart-marks/9729226fcc03e4eedfc5e7f282566e60 to your computer and use it in GitHub Desktop.
Processing Large Files in Java, Variation 4
--- ReadFileJavaApplicationBufferedReader3.java 2019-01-05 20:40:01.000000000 -0800
+++ ReadFileJavaApplicationBufferedReader4.java 2019-01-05 20:40:05.000000000 -0800
@@ -45,7 +45,7 @@
Instant commonNameStart = Instant.now();
ArrayList<String> firstNames = new ArrayList<>();
- var namePat = Pattern.compile(", \\s*(([^ ]*), |([^ ]+))");
+ var namePat = Pattern.compile(", \\s*([^, ]+)");
System.out.println("Reading file using " + Caller.getName());
@@ -59,11 +59,7 @@
var matcher = namePat.matcher(name);
if (matcher.find()) {
- String s = matcher.group(2);
- if (s == null) {
- s = matcher.group(3);
- }
- firstNames.add(s);
+ firstNames.add(matcher.group(1));
}
String rawDate = array1[4].strip();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment