Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...