Litigation Support Tip of the Night
top of page

In order to find and replace multiple strings using regular expression you can use this format:


Find: (FindA)|(FindB)|(FindC)...

Replace: (?1ReplaceA)(?2ReplaceB)(?3ReplaceC)...


However if the operation is run this way it will not take word boundaries into consideration and will replace strings you search for which appear in the middle of other words. So if you run a search like this to capitalize the first names in a list of addresses:





. . .the search will not only capitalize 'Beth' but will also capitalize the string 'beth' in 'ElizaBeth'.


To prevent strings which are not words from being altered by the regex search use word boundaries around the searched for terms:


(\bbeth\b)|(\bmelissa\b)|(\bsusan\b)|(\bjennifer\b)






213 views0 comments

If you want to highlight multiple strings in a Word document, you can do so by utilizing a simple macro posted here, by Susan Harkins with Tech Republic.


In this example we have a document in which we want to search for any one of five terms.



Edit the macro, posted below, so that the strings or words we want to highlight are listed one by one in the lines beginning 'WordCollection'. Set the number for each of these things in the parentheses after 'WordCollection' so that each term is successively numbered, but begin with zero:




On the third line set the number after 'Dim WordCollection' in parentheses to the match number of terms you're searching for. To be clear, if the last term is preceded by 'WordCollection(4)' set the number on the third line of the visual basic code to 5.


You can set the color of the highlighting on the first operative line after those in which the searched for terms are listed.




The macro does take a good deal of time to run. If you are searching for multiple strings in a long document, it may take several minutes to finish running.



Searched for strings which appear as part of longer words will be highlighted.


As always, this was tested and confirmed to work correctly by Litigation Support Tip of the Night.




Sub HighlightWords()


Dim Word As Range


Dim WordCollection(5) As String


Dim Words As Variant


'Define list.


'If you add or delete, change value above in Dim statement.


WordCollection(0) = "whale"


WordCollection(1) = "Ahab"


WordCollection(2) = "sailor"


WordCollection(3) = "sea"


WordCollection(4) = "ivory"


'Set highlight color.


Options.DefaultHighlightColorIndex = wdPink


'Clear existing formatting and settings in Find feature.


Selection.Find.ClearFormatting


Selection.Find.Replacement.ClearFormatting


'Set highlight to replace setting.


Selection.Find.Replacement.Highlight = True


'Cycle through document and find words in collection.


'Highlight words when found.


For Each Word In ActiveDocument.Words


For Each Words In WordCollection


With Selection.Find


.Text = Words


.Replacement.Text = ""


.Forward = True


.Wrap = wdFindContinue


.Format = True


.MatchCase = False


.MatchWholeWord = False


.MatchWildcards = False


.MatchSoundsLike = False


.MatchAllWordForms = False


End With


Selection.Find.Execute Replace:=wdReplaceAll


Next


Next


End Sub







52 views0 comments

If you want to find out the last time a Windows 11 PC was powered on, or shut down you can use the Event Viewer application.

Bring up Event Viewer by searching for it Windows. It will be preinstalled.








In Event Viewer, open the Windows Log menu and click on 'System'



















Bring up 'Filter Current Log' from the Actions pane on the right. Enter '6005' in the Event ID field.



You can sort in the results by the date and time to find the latest time the PC was started.


Use 6006 as the Event ID to find when the PC was shut down.




24 views0 comments
bottom of page