Stephan van Hulst wrote:
Darryl Burke wrote:What's wrong with sentence.replaceAll("(?:\\b)[a-z]*(?:\\b)", "")? And if the double spaces left behind are an issue, that could be chained to .replace(" ", " ").
That regular expression does not take into account that the sentence could consist of characters other than a-z, A-Z and spaces.
Stephan van Hulst wrote:Also, the second replace would have to be performed multiple times until there are no more changes.
String#replace(CharSequence target, CharSequence replacement) wrote:Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.
Campbell Ritchie wrote:I am pretty sure that is what I did.
Campbell Ritchie wrote:
Campbell Ritchie wrote:Since paintShape takes a Graphics parameter, can you simply use a method reference?