Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-24-2025, 06:49 PM
anniewong anniewong is offline How to Use Wildcards to Find Specific Text Patterns  with sub-levels Mac OS X How to Use Wildcards to Find Specific Text Patterns  with sub-levels Office 2021
Novice
How to Use Wildcards to Find Specific Text Patterns  with sub-levels
 
Join Date: Jan 2025
Posts: 1
anniewong is on a distinguished road
Default How to Use Wildcards to Find Specific Text Patterns with sub-levels

How to Use Wildcards to Find Specific Text Patterns When Some Text is Part of the Text ?Any help would be appreciated


I have list of pattern to search the text , which is

Example Patterns:
1.1
1.1(a)
1.12
1.12(a)
1.12(b)

Example document to search:
1.1 1.12(a) 1.1(a) 1.12 1.12(a) 1.12(b) 1.1

Issues:
  • When I search with 1.1 first, it will match all 1.1(a) , 1.12 , 1.12(a) , 1.12(b) with wildcard search.
  • Using the wildcard pattern "Rule 1.1[!( ]" fails to match 1.1 if it appears at the end of a sentence..
  • Using the whole word match , it doesn't work because its number , not a word

I am using mac so can't use regular expression which just much more easier to do it .

PHP Code:
Selection.Find.ClearFormatting
    With Selection
.Find
        
.Text "Rule 1.1[!( ]"
        
.Forward True
        
.Wrap wdFindAsk
        
.Format False
        
.MatchCase False
        
.MatchWholeWord False
        
.MatchByte False
        
.MatchAllWordForms False
        
.MatchSoundsLike False
        
.MatchWildcards True
    End With
    
Do While Selection.Find.Execute
        Selection
.Range.HighlightColorIndex wdYellow
    Loop
End Sub 
Reply With Quote
  #2  
Old 01-24-2025, 09:27 PM
macropod's Avatar
macropod macropod is offline How to Use Wildcards to Find Specific Text Patterns  with sub-levels Windows 10 How to Use Wildcards to Find Specific Text Patterns  with sub-levels Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,366
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

.Text = "[0-9].[0-9a-z\(\)]{1,}"

Code:
Sub Demo()
Application.ScreenUpdating = False
Options.DefaultHighlightColorIndex = wdYellow
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[0-9].[0-9a-z\(\)]{1,}"
    .Replacement.Highlight = True
    .Replacement.Text = "^&"
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Forward = True
    .Format = True
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Use Wildcards to Find Specific Text Patterns  with sub-levels Find and replace text in a document with wildcards in vba marcotte974 Word VBA 2 06-22-2022 10:38 PM
How to Use Wildcards to Find Specific Text Patterns  with sub-levels VBA Find and Replace for sub levels Shelley Lou Word VBA 2 06-21-2021 12:45 AM
How to Use Wildcards to Find Specific Text Patterns  with sub-levels find/replace all text not a specific colour? LQuinn Word VBA 3 04-06-2021 04:51 PM
How to Use Wildcards to Find Specific Text Patterns  with sub-levels Find and replace text with wildcards arunchandar9 Word VBA 15 06-30-2019 01:06 AM
Using wildcards how do I Find and Add to, not replace Stargehzer Word 3 01-25-2016 09:14 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft