While reading and learning about regex, I have been trying to figure out why I go wrong in the current usage of my regex?
The string I have is
String sentence = "I would've rather stayed at home, than go to the Murphys' home, on the 'golden' weekend";
The current replaceAll argument I use is:
String[] tokens = sentence.replaceAll("[^\\sA-Za-z']+", "").split("\\s+");
This gives me an array of tokens that looks like
tokens = {"I", "__would've__", "rather", "stayed", "at", "home", "than", "go", "to", "the", "__Murphys'__", "home", "on", "the", "__'golden'__", "weekend"};
But I would like to remove the apostrophe from Murphys' to Murphys and 'golden' to golden while would've stays as would've.
Giving me an array that looks like
correctTokens = {"I", "__would've__", "rather", "stayed", "at", "home", "than", "go", "to", "the", "__Murphys__", "home", "on", "the", "__golden__", "weekend"};
Your help would be greatly appreciated