View Single Post
 
Old 03-07-2023, 03:56 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The plural of appendix is not just adding an s to the end. It is normally appendixes or appendices. The problem you are having is that you are enclosing the find text in a single set of (brackets) when you need two separate sets if you want to replace something inside there.

This would all be a lot more straightforward if you simply expand the array to include all acceptable plurals.
Code:
  Dim arr() As String, i As Integer, sFind As String
  sFind = "[Aa]ppendix [Aa]ppendixes [Aa]ppendices [Cc]lause [Cc]lauses [Pp]aragraph [Pp]aragraphs [Pp]art [Pp]arts [Ss]chedule [Ss]chedules"
  arr = Split(sFind, " ")
  With ActiveDocument.Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .MatchWildcards = True
    For i = 0 To UBound(arr)
      .Text = "(" & arr(i) & ") ([0-9.]{1,})"
      .Replacement.Text = "\1^s\2"
      .Execute Replace:=wdReplaceAll
    Next
  End With
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote