Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Find & Replace Words all Caps 1

Status
Not open for further replies.
Jun 5, 2002
417
AU
Hi,

I am copying results from the French Open Tennis.

This is what I get for each match in Word after I have pasted from the website:

Men’s Singles - First Round
Court Suzanne-Lenglen - 2h10
FABBIANO T.Fabbiano
3 5 1 - -
CILIC M.Cilic (11)
6 7 6 - -

Can I code a Find & Replace that will remove the All Caps names followed by the 2 spaces and leave all else as is.

There are about 60 of these entries for each day of the first week's play, so it is a bore to do manually.

Apologies for my knowledge in this area.

Any help greatly appreciated.

Peter Moran
 
Yes, this is fairly simple to do with a Find and Replace supporting wildcards (and thus a subset of regular expressions).

Code:
[blue]    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = "[A-Z]{1,}  " [green]' Word regexp[/green]
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With[/blue]
 
Hi strongm,

Many thanks, got me going and with a little perseverence found that the text I needed was "^13<[A-Z]{2,12}> "

Great work!

Peter Moran
 
Glad you got it working (although your regexp meets a slightly differnt requirement than you originally posted!)
 
You could reduce the wildcard Find expression to:
^13[A-Z]{2,12}>
or even:
^13[A-Z]{2,}>

Cheers
Paul Edstein
[MS MVP - Word]
 
Hi Paul,

Many thanks, I found a few extra variants in my processing, but basically inline with your thoughts.

Peter Moran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top