Reputation: 17
Hello: I am trying to perform either a regular search or wildcard search in Word, specifically in the Endnotes. Here is what I am searching for: [Endnote Reference][space][text....][:]
Here is an example of what the endnote might look like: 12 Text in my endnote ending with a colon: More text but not what I want.
So what I want to do is select all the text (plus colon) following the Endnote Reference + space (i.e., Text in my endnote ending with a colon:) and add bold/italics. I've tried using the advance search where I search for: ^e^?: --> doesn't work (I'd like to make the "any character" a bunch of characters until the : is reached) Wildcard search does not allow the use of ^e so I tried: *L --> that gives way too much and then also doesn't work.
Any feedback is much appreciated. I could accomplish this in Perl, but not in Word. thanks in advance!
Upvotes: 0
Views: 243
Reputation: 13515
You don't need Regex for this. All you need is a wildcard Find, where:
Find = ^2 [!^13]@:
Using VBA for what you're trying to do:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.StoryRanges(wdEndnotesStory)
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^2 [!^13]@:"
.Replacement.Text = ""
.Forward = True
.Format = False
.Wrap = wdFindStop
.MatchWildcards = True
End With
Do While .Find.Execute
.Start = .Endnotes(1).Range.Start
.Style = "MyBoldItalicCharacterStyle"
.Collapse wdCollapseEnd
Loop
End With
Application.ScreenUpdating = True
End Sub
Upvotes: 1