replace Enter character \r\n - Android java.lang

Android examples for java.lang:Character

Description

replace Enter character \r\n

Demo Code

import android.text.TextUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String replaceEnter(String oldString) {
        if (TextUtils.isEmpty(oldString)) {
            return "";
        }/*from  w w  w  . java 2  s .  c  o m*/
        Pattern pattern = Pattern.compile("(\r\n|\r|\n|\n\r)");
        Matcher matcher = pattern.matcher(oldString);
        String newString = matcher.replaceAll("<br>");
        return newString;
    }

}

Related Tutorials