remove Blank Lines from string using replaceAll and regular expression - Android java.util.regex

Android examples for java.util.regex:Blank Remove

Description

remove Blank Lines from string using replaceAll and regular expression

Demo Code


public class Main{

    public static String rmvBlankLines(String input) {
        return input.replaceAll("((\r\n)|\n)[\\s\t ]*(\\1)+", "$1");
    }/*  w  ww  . java 2s  . c o  m*/

}

Related Tutorials