⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e446. removing line termination characters from a string.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
A line termination character sequence is a character or character pair from the set: \n, \r, \r\n, \u0085, \u2028, and \u2029. 
Note: The character pair \n\r is considered a two-line terminator character and therefore will be replaced with two spaces. 

    // Returns a version of the input where all line terminators
    // are replaced with a space.
    public static CharSequence removeLineTerminators(CharSequence inputStr) {
        String patternStr = "(?m)$^|[\\r\\n]+\\z";
        String replaceStr = " ";
        Pattern pattern = Pattern.compile(patternStr);
        Matcher matcher = pattern.matcher(inputStr);
        return matcher.replaceAll(replaceStr);
    }

 Related Examples 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -