Last active
January 7, 2019 00:06
-
-
Save stuart-marks/9729226fcc03e4eedfc5e7f282566e60 to your computer and use it in GitHub Desktop.
Processing Large Files in Java, Variation 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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