![]() |
|
|
|
#1
|
||||
|
||||
|
Quote:
If you want something that will catch all the examples you have now given, you could use: Find =, [A-Z][!,]@ [A-Z][!,]@, This will capture all instances of a comma, followed by a space, then a proper-case word, any number of characters other than a comma, finally a space and another proper-case word (hyphenated or otherwise) before a comma. Again, the macro equivalent to italicize all such text (since I still don't know what you want to do with what you find) would be: Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Font.Italic = True
.Text = ", [A-Z][!,]@ [A-Z][!,]@,"
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Capture group in RegEx
|
alex100 | Word VBA | 1 | 01-02-2021 02:39 PM |
Regex over 700 matches in a long doc
|
totoMSOF | Word VBA | 19 | 03-11-2019 01:28 PM |
Using VB Regex feature, I tried to replace 'the' and 'this' with 'that' but got screwed
|
abdan | Word VBA | 3 | 01-18-2019 09:38 PM |
| Macro help regex | subspace3 | Word VBA | 1 | 10-15-2014 09:53 AM |
| Regex in Word: Replaced strings are in disorder | chgeiselmann | Word | 0 | 04-26-2009 11:33 AM |