I'm working on my assignment which is to read in from a dictionary list, and a paragraph and count the amount of times certain words show up in the paragraph, all while using LinkedLists and BSTs. We have been given the regex command to split apart the paragraph.txt file, the command is "[\\s|\\pPunct]+"
which does not work for me, so instead I am using [\\s, ?!]+
however this isn't doing everything which I want it to, and since regex commands are outside the abstract of this course I don't know much about them.
I'm looking for a command which removes all periods, commas, and whitespace. [\\s, ?!]+
does the first two, however if I have this line for example;
..some line here
more text here...
That return line is not removed, I tried to remove it when I added each word into my LinkedList with;
public static void insertParagraph(String[] strings) {
for(int i = 0; i < strings.length; i++) {
if(strings[i] != "" || strings[i] != " " || strings[i] != null)
paragraph.insertFirst(strings[i].replaceAll("[^a-zA-Z'\\s]","").toLowerCase());
}
}
However that if statement doesn't work either, does anyone have any suggestions?