assert CharSequenceUtils.isNotBlank(text) && CharSequenceUtils.isNotBlank(commentStart) && CharSequenceUtils.isNotBlank(commentEnd);
final EnhancedStringBuilder builder = new EnhancedStringBuilder(text).deletePattern("\r");
final Collection<MatchEntry> newLines = builder.findPattern("\n");
for (MatchEntry match : newLines) {
if (match.getStart() > 0 && isPeriodFinalization(builder.charAt(match.getStart() - 1))
&& '\n' != builder.charAt(match.getStart() + 1)) {
/* new lines not after a punctuation are removed */
builder.replace(match, " ");
}
}
builder.replacePattern(" +", " ");