Java examples for java.util.regex:Match New Line
remove Carriage Return with regex
//package com.java2s; public class Main { public static void main(String[] argv) { String query = "boo\r\n\n\n\nk2s.com"; System.out.println(removeCarriageReturn(query)); }//from w w w . j ava2 s . c om public static String removeCarriageReturn(String query) { // query.replaceAll(regex, replacement) String result = query.replaceAll("[\r\n]", " "); return result; } }