update bible word counter

This commit is contained in:
SowinskiBraeden committed 2025-03-21 11:24:06 -07:00
1 parent 3ed6260318
commit 667f6fcba5
1 file changed
+5 -3
@@ -37,7 +37,9 @@ public class WordCounter {
lineScan.useDelimiter(" "); lineScan.useDelimiter(" ");
while (lineScan.hasNext()) { while (lineScan.hasNext()) {
String word = lineScan.next().toLowerCase(); String word = lineScan.next().
toLowerCase().
replaceAll("[^a-z]", "");
boolean exists = false; boolean exists = false;
for (int i = 0; i < words.size() && !exists; i++) { for (int i = 0; i < words.size() && !exists; i++) {
@@ -47,8 +49,8 @@ public class WordCounter {
exists = true; exists = true;
} }
} }
if (!exists && Pattern.matches("^[a-zA-Z]+", word)) { if (!exists && Pattern.matches("^[a-z]+", word)) {
words.add(new Word(word)); words.add(new Word(word));
} }
} }