Regexp break long lines [duplicate]

给你一囗甜甜゛ 提交于 2019-12-25 18:52:14

问题


I want to break long lines for 5 characters and doesn`t touch short lines:

aaa bbbbbbb cc dddddddddddd

into

aaa bbbbb bb cc ddddd ddddd dd

I`ve found way to find only long lines: ^(.{5,}) , but I've no idea how to break it to fives several times.

Another way is: find .{0,5}(\s*|$) replace $0\n - it works but after each previous line it creates new empty line. Even after short lines.

I`m testing in Sublime Text 3. So maybe some Sublime plugin could do it as well.


回答1:


A line break can be inserted like this :

Find ([^\r\n]{5}) replace $1\r\n

https://regex101.com/r/dTeMbq/1



来源:https://stackoverflow.com/questions/59413771/regexp-break-long-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!