How exactly do regular expressions work in Java? Let's say I have the string:
Code :String test = new String("Sally went to the barn."); //any string will do this is for experimentation purposes
and I wanted to use the String's split() function... or any regEx function to get all the words out and put them into a neat little ArrayList<String> (or even better a Hashtable<String, Integer> that'll count the amount of times each word appears).
I tried:
Code :String regEx = "\w"; String[] splitter = test.split(regEx); for(int i=0;i<splitter.length;i++){ System.out.println(splitter[i]); }
But the compiler tells me that "\w" is "an invalid escape sequence. How would I go about extracting every word from a string and putting it into a data structure? Please help, I'm so lost.

