本文介绍了如何将长行分成五个字符的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将长行分成五个字符并忽略短行:
I want to break long lines into five characters and ignore short lines:
aaa
bbbbbbb
cc
dddddddddddd
进入
aaa
bbbbb
bb
cc
ddddd
ddddd
dd
我找到了只找到长行的方法:
I found way to find only long lines:
^(.{5,})
但我不知道如何多次将其分成五个字符行.
but I've no idea how to break it to five character lines several times.
另一种方法是:找到 .{0,5}(\s*|$)
并替换为 $0\n
.它可以工作,但在每行之后都会创建一个新的空行,即使在短行之后也是如此.
Another way is: find .{0,5}(\s*|$)
and replace with $0\n
. It works but after each previous line it creates a new empty line, even after short lines.
我正在 Sublime Text 3 中进行测试,所以也许某些 Sublime 插件也能做到?
I'm testing in Sublime Text 3, so maybe some Sublime plugin could do it as well?
推荐答案
可以这样插入换行符:
查找([^\r\n]{5})
替换$1\r\n
https://regex101.com/r/dTeMbq/1
这篇关于如何将长行分成五个字符的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!