01 02 03 04 05 06 07 08 09 10 11 12 13 14 | import java.util.regex.Matcher; import java.util.regex.Pattern; public static String replaceLineBlanks(String str) { String result = "" ; if (str == null || "" .equals(str)) { Pattern p = Pattern.compile( "(r?n(s*r?n)+)" ); Matcher m = p.matcher(str); result = m.replaceAll( "rn" ); } return result; } |