View Single Post
 
Old 10-21-2023, 08:07 PM
zpy2 zpy2 is offline Windows 10 Office 2013
Novice
 
Join Date: Sep 2023
Location: China
Posts: 28
zpy2 is on a distinguished road
Default

Sub SingleBeforeDigit()

Dim regEx As Object

Dim match As Object

Dim fullNamePattern As String



' Create a RegExp object

Set regEx = CreateObject("VBScript.RegExp")



' Set the regular expression pattern for a full name

fullNamePattern = "‘(?=\d)"



With regEx

.Global = True ' Set global matching mode

.Pattern = fullNamePattern ' Assign the pattern



' Loop through all matches of the full name pattern

For Each match In .Execute(ActiveDocument.Content.Text)

' Replace the matched text

ActiveDocument.Range(match.FirstIndex, match.FirstIndex + Len(match.Value)).Text = chr(136)

Next match

End With

End Sub
Reply With Quote