public static String tidyString(String string){
  if (string.matches(".*?\\.$")) {
    return string;
  }
 else {
    return string.replaceAll("(\\p{Punct}+\\z)|(\\A\\p{Punct}+)","");
  }
}

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