For a VBA solution, try:
Sub Demo()
Dim Rng As Range, Rslt
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[‘'][!^13^l^t]@['’]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
.Select
Set Rng = .Duplicate
With Rng
.Start = .Start + 1
.End = .End - 1
If .Text <> Trim(.Text) Then
Rslt = MsgBox("Trim this instance?", vbYesNoCancel)
If Rslt = vbCancel Then Exit Sub
If Rslt = vbYes Then
Do While .Characters.Last = " "
.Characters.Last = vbNullString
Loop
Do While .Characters.First = " "
.Characters.First = vbNullString
Loop
End If
End If
End With
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
End Sub
Note: If the strings don't have any formatting applied, you could reduce:
Do While .Characters.Last = " "
.Characters.Last = vbNullString
Loop
Do While .Characters.First = " "
.Characters.First = vbNullString
Loop
to:
.Text = Trim(.Text)
To work with just a selected range, change:
Dim Rng As Range, Rslt
With ActiveDocument.Range
to:
Dim Rng As Range, RngSel As Range, Rslt
With Selection.Range
Set RngSel = .Duplicate
and insert:
If .InRange(RngSel) = False Then Exit Sub
before:
.Select
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…