Hello, @i-hay, @coises and All,
I found out an easy solution to your problem ! To that purpose, I used the the Edit > Line Operations > Reverse Line Order menu option, which is quite powerful when multi-lines regex is involved !
So, let’s consider your INPUT text :
No Name Relationship Date of Birth Date of Death Age Other information
1 Fred BLOGGS May 13 1800 93 yrs Brotherton
Liz wife Apr 39 1840 64 yrs
Ann DIRGEWALL (husband : Jay) Jny 2 1955 61 yrs Gable St
2 Unmarked grave
3 Unmarked grave
4 Jack GARDNER Dec 5 1967 75 yrs Grove Rd
Jane wife Sep 2 1969 70 yrs Blackpool
Mary JONES wife of Adam Jly 4 1930
5 Henry ALBERT Jny 4 1900 68 yrs Abbeyrange
Lola wife Dec 28 1909 76 yrs
Jack HARBOR son in law Jan 29 1976 49 yrs
Julie wife May 29 1999 72 yrs
First, select all the text, which needs re-numbering
Use the Edit > Line Operations > Reverse Line Order menu option
=> You should get this temporary OUTPUT text :
Julie wife May 29 1999 72 yrs
Jack HARBOR son in law Jan 29 1976 49 yrs
Lola wife Dec 28 1909 76 yrs
5 Henry ALBERT Jny 4 1900 68 yrs Abbeyrange
Mary JONES wife of Adam Jly 4 1930
Jane wife Sep 2 1969 70 yrs Blackpool
4 Jack GARDNER Dec 5 1967 75 yrs Grove Rd
3 Unmarked grave
2 Unmarked grave
Ann DIRGEWALL (husband : Jay) Jny 2 1955 61 yrs Gable St
Liz wife Apr 39 1840 64 yrs
1 Fred BLOGGS May 13 1800 93 yrs Brotherton
No Name Relationship Date of Birth Date of Death Age Other information
Now, move back at the beginning of the reversed text
Open the Replace dialog ( Ctrl + H )
Uncheck all the box options
FIND (?s)^\x20(?=(?:.+?)^(\d+))
REPLACE \1
Select the Regular expression search mode
Click, once only, on the Replace All button
=> Your temporary text is then changed into : :
5 Julie wife May 29 1999 72 yrs
5 Jack HARBOR son in law Jan 29 1976 49 yrs
5 Lola wife Dec 28 1909 76 yrs
5 Henry ALBERT Jny 4 1900 68 yrs Abbeyrange
4 Mary JONES wife of Adam Jly 4 1930
4 Jane wife Sep 2 1969 70 yrs Blackpool
4 Jack GARDNER Dec 5 1967 75 yrs Grove Rd
3 Unmarked grave
2 Unmarked grave
1 Ann DIRGEWALL (husband : Jay) Jny 2 1955 61 yrs Gable St
1 Liz wife Apr 39 1840 64 yrs
1 Fred BLOGGS May 13 1800 93 yrs Brotherton
No Name Relationship Date of Birth Date of Death Age Other information
Finally, redo a
Edit > Line Operations > Reverse Line Order menu option
Here we are ! We get your expected OUTPUT text, below :
No Name Relationship Date of Birth Date of Death Age Other information
1 Fred BLOGGS May 13 1800 93 yrs Brotherton
1 Liz wife Apr 39 1840 64 yrs
1 Ann DIRGEWALL (husband : Jay) Jny 2 1955 61 yrs Gable St
2 Unmarked grave
3 Unmarked grave
4 Jack GARDNER Dec 5 1967 75 yrs Grove Rd
4 Jane wife Sep 2 1969 70 yrs Blackpool
4 Mary JONES wife of Adam Jly 4 1930
5 Henry ALBERT Jny 4 1900 68 yrs Abbeyrange
5 Lola wife Dec 28 1909 76 yrs
5 Jack HARBOR son in law Jan 29 1976 49 yrs
5 Julie wife May 29 1999 72 yrs
Some details about the search regex :
First, the (?s) syntax is an in-line modifier which has the same effect that checking the . matches newline option of the Replace dialog
Then, the regex just looks for a space character \x20, at beginning of a line ( ^ ), ONLY IF it is followed with a look-ahead syntax ((?=..........) ), coming next
This structure looks, itself, for any character, even new-line char(s), in a non-capturing group ( (?:....) ) , till the nearest line ( .+? ), beginning by a number ( ^\d+ ), that is stored as group 1, due to the embedded parentheses ( (\d+) )
In replacement, any space character ( \x20 ) is then replaced with the contents of the group 1, which is our desired number !
Best Regards,
guy038