Java正则表达式:换行符+空格 [英] Java regex: newline + white space

查看:1160
本文介绍了Java正则表达式:换行符+空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该很简单,但我会发疯了。

should be simple, but I'm going crazy with it.

给出如下文字:

line number 1
line number 2
 line number 2A
line number 3
 line number 3A
 line number 3B
line number 4

我需要删除行终止符的Java正则表达式,然后新行以空格开头,以便上面的示例文本变为:

I need the Java regex that deletes the line terminators then the new line begin with space, so that the sample text above become:

line number 1
line number 2line number 2A
line number 3line number 3Aline number 3B
line number 4


推荐答案

yourString.replaceAll(\ n,); 这不会有帮助吗?

这篇关于Java正则表达式:换行符+空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆