Situation: You have a completed back-of-the-book index for a book, perhaps created with PDF Index Generator. You are then required to add a further page to the book, that you thought was finished. Such a change will ‘throw off’ most of the numbers in the index, but not all of them. Only the page-numbers after the point where the new page was added. Do you need to remake the index again? No.

Solution: You use the following Microsoft Word macro to do the required ‘intelligent corrections’ of the changed numbers in the Index.

Use: Copy-paste the kaput Index to a new Word document of the same page size, with retained formatting. Edit the macro’s three variable numbers for your needs and load it. Run it. Copy back the results to the book. Check the new index aligns with the book.

Change the numbers indicated. The first number is the increment, and the other is the page number above which incrementing is done.

' WORD MACRO - Increment the numbers in the back-of-a-book index by x, only if above a certain number.
Sub Demo()
Application.ScreenUpdating = False
' Change the following number 1 to the increment you need. Number of pages added = the number you need.
Const i As Long = 1
With ActiveDocument.Range
With .Find
.ClearFormatting
.Text = "<[0-9]{2,3}>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
' Change the next number to the page-number below which all must stay the same.
If CLng(.Text) > 77 Then
' Page number 2000 is the ending backstop number - change this only if you have a monster book.
If CLng(.Text) < 2000 Then .Text = CLng(.Text) + i End If .Collapse wdCollapseEnd .Find.Execute Loop End With Application.ScreenUpdating = True End Sub Change the numbers to suit your situation.

Here the above macro is set to increment by 1, any page-number it finds in the index. But only if it has a value between 77 and 2000. You are assumed to have added one new page at page 76. Any indexed page number for page 77 must therefore now become 78, and so on. Numbers are recognised individually, even if in the hyphenated form, e.g.: 99-100 or similar.

Your index is assumed to have no dates or street numbers used as index terms, e.g. “1066 A.D., Battle of Hastings, p. 356”, or “221B Baker Street, p. 73”.

The newly added page(s) will of course need to have their new entries indexed, if not simply illustrations, and manually added to the revised index.

So far as I can tell, there’s no way to do this with a regex.