question: public static String tidyString ( String string ) { if ( string . matches ( ".*?\\.$" ) ) { return string ; } else { return string . replaceAll ( "(\\p{Punct}+\\z)|(\\A\\p{Punct}+)" , "" ) ; } }
target:  Removed punctuation from the begging or end of input if it does not appear to be a sentence ending with a period.