Note: My program works, I am just looking for an explanation as to why.
I have a java program that reads a file, counts the words in said file, and outp
There's nothing special about an underscore in a regular expression, it's just a normal character like A. A hyphen at the end of a character class isn't special either, although it is when between two other characters, as you've used it to match all letters by saying A-Z for example.
Regular expressions are similar between most languages, but some of the more esoteric features can be different or missing from a language.