Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

regex - Replace Rows in Notepad++

I'd like to convert stuff like this:

bitte
----------

dream
----------


----------

HD
----------

ready
----------

into stuff like this:

bitte:dream
HD:ready

using a regex. What regex to use? How to put all this rows together?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You may use a regex like

^(?:---+Rs*)*(w.*)R---+R(?:h*R)*(w.*)R---+$

And replace with $1:$2.

The ^ matches the line start, (?:---+Rs*)* matches optional delimiter lines before the first non-empty line, (w.*) is Group 1 capturing a word char followed with 0+ chars other than a newline, R---+R matches a line break followed with 3+ hyphens and a linebreak, (?:h*R)* matches n number of blank lines, (w.*) (see above) and R---+$ matches a linebreak and 3+ hyphens at the end of the line.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...