Hello @ahmed-izler and All,
Here is my solution… with regexes, of course ;-))
So, given this example, below, where :
Three sections, out of five, end with Option 2
A variable amount of empty lines, even 0, exists between sections
Two sections are preceded with leadings space and tabulation characters
vorname: Alfred
nachname: Weber
geburtsdatum: 17.01.1981
Strasse: Wolfgangstraße
HausNr: 12
PLZ: 45598
Wohnort: Essen
Etage: EG
Lage: links
Tel: 0176048784263
email: richardweber1m@yahoo.com
IBAN: DE4XXXXXXXXXXXXXXXXX5
XXXXXXXXXX
Option 2
vorname: Alfred
nachname: Weber
geburtsdatum: 17.01.1981
Strasse: Wolfgangstraße
HausNr: 12
PLZ: 45598
Wohnort: Essen
Etage: EG
Lage: links
Tel: 0176048784263
email: richardweber1m@yahoo.com
IBAN: DE4XXXXXXXXXXXXXXXXX5
XXXXXXXXXX
vorname: Alfred
nachname: Weber
geburtsdatum: 17.01.1981
Strasse: Wolfgangstraße
HausNr: 12
PLZ: 45598
Wohnort: Essen
Etage: EG
Lage: links
Tel: 0176048784263
email: richardweber1m@yahoo.com
IBAN: DE4XXXXXXXXXXXXXXXXX5
XXXXXXXXXX
Option 2
vorname: Alfred
nachname: Weber
geburtsdatum: 17.01.1981
Strasse: Wolfgangstraße
HausNr: 12
PLZ: 45598
Wohnort: Essen
Etage: EG
Lage: links
Tel: 0176048784263
email: richardweber1m@yahoo.com
IBAN: DE4XXXXXXXXXXXXXXXXX5
XXXXXXXXXX
vorname: Alfred
nachname: Weber
geburtsdatum: 17.01.1981
Strasse: Wolfgangstraße
HausNr: 12
PLZ: 45598
Wohnort: Essen
Etage: EG
Lage: links
Tel: 0176048784263
email: richardweber1m@yahoo.com
IBAN: DE4XXXXXXXXXXXXXXXXX5
XXXXXXXXXX
Option 2
Open the Replace dialog ( Ctrl + H )
SEARCH (?s)^\h*vorname:.+?(\R)(\h*Tel:\h+.+?\R\h*email:\h+.+?\R).+?\R(\h*Option 2\R*)?(?=\h*vorname:|\z)
REPLACE ?3\2\1
Tick the Wrap aroud option, if necessary
Select the Regular expression search mode
Click on the Replace All button, or several times on the Replace button
You’ll get this output, with the indentation kept :
Tel: 0176048784263
email: richardweber1m@yahoo.com
Tel: 0176048784263
email: richardweber1m@yahoo.com
Tel: 0176048784263
email: richardweber1m@yahoo.com
So, @ahmed-izler, if this result is the one that you expect to, I’ll give you some hints on the regex S/R, next time !
Best Regards
guy038