如何使用正则表达式删除两行之间的空格? [英] How to use regex to remove the spaces between two rows?

查看:30
本文介绍了如何使用正则表达式删除两行之间的空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的输入文件是这样的

Header1,,,,,,,,,,,
c1 , c2 , c3 ,,,,

 22-02-2017,1-2,10,,,,
 22-02-2017,2-3,11,,,,

 22-02-2017,4-6,10,,,,
 22-02-2017,5-8,11,,,,

我需要正则表达式才能达到低于预期的输出:

I need to regex to achive below expected output:

Header1,,,,,,,,,,,
c1 , c2 , c3 ,,,,
22-02-2017,1-2,10,,,,
22-02-2017,2-3,11,,,,
22-02-2017,4-6,10,,,,
22-02-2017,5-8,11,,,,

我尝试使用此正则表达式在 REplaceTExt 中搜索 \s\n,替换值为 \n.

I trying this regex for search \s\n in REplaceTExt and replacement value is \n.

替换文本输出内容如下.

After Replace text output content like below.,

Header1,,,,,,,,,,,c1 , c2 , c3 ,,,,22-02-2017,1-2,10,,,,22-02-2017,2-3,11,,,,22-02-2017,4-6,10,,,,

但我的正则表达式在 regexr 网站上运行良好.

But my regex worked perfectly in regexr website.

http://regexr.com/3fbse

是否有其他正则表达式可以搜索空行并合并空行前后的行?

Is there is any other regex to search empty rows and combine rows before and after of empty rows?

推荐答案

搜索:\n\n\s|\n\s

替换:\n

正则表达式演示

这篇关于如何使用正则表达式删除两行之间的空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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