View Single Post
 
Old 01-18-2019, 07:53 PM
abdan abdan is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2018
Posts: 4
abdan is on a distinguished road
Default Using VB Regex feature, I tried to replace 'the' and 'this' with 'that' but got screwed

I tried to replace 'the' and 'this' with 'that' by using VB Regex feature on Word with the applied strings (ie. document) having font size mostly 10 and 18 for titles, but it resulted in entire strings having font size 18, although the regex seems works correctly (I can't read well)

Sub Regex_Replace
Dim re As Object, match As Object, matches As Object
Set re = CreateObject("VBScript.RegExp")
With re
.Global = True
.IgnoreCase = True
.Pattern = "(th)(e|is)\b"
ActiveDocument.Range.Text = .Replace(ActiveDocument.Range.Text, "$1at")
End With
End Sub

I can't read the document now as it got messed up and screwed with crammed words with font size 18.
How to solve it?
Sincere help would really be appreciated
Reply With Quote