R
Ronnie
How do I delete p1 through p669 using wildscards?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
p[0-9]{1,3}[!0-9]

Helmut Weber said:Hi Herb,
p[0-9]{1,3}[!0-9]
that was the trap I fell into as well.
It finds "p123A". :-(
I thought about something like that:
Sub Test669()
Dim rDcm As Range
For x = 1 To 669 ' brute force
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "p" & CStr(x)
While .Execute
If Not rDcm.Characters.Last.Next Like "#" Then
rDcm.HighlightColorIndex = wdBrightGreen
End If
Wend
End With
Next
End Sub
Then delete the such highlighted text.
Which rises the question,
is there an otherwise not used highlighting in the doc?
Black, I think, might be a 999999:1 chance.
I've never heard of someone,
highlighting text in black.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP
Herb Tyson said:Another possibility would be to create another [] set that includes all of
the acceptable characters that might follow a p### you want to match.
Presumably, these would be things like a space, period, comma, colon,
semicolon, etc. So, p[0-9]{1,3}[ .,;:etc.] might do the trick... assuming
that the OP was using p669 as an example rather than an explicit upper limit
(and values above 669 are also something you want to zap),
--
Herb Tyson MS MVP
Author of the Word 2007 Bible
Blog: http://word2007bible.herbtyson.com
Web: http://www.herbtyson.com
Helmut Weber said:Hi Herb,
p[0-9]{1,3}[!0-9]
that was the trap I fell into as well.
It finds "p123A". :-(
I thought about something like that:
Sub Test669()
Dim rDcm As Range
For x = 1 To 669 ' brute force
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "p" & CStr(x)
While .Execute
If Not rDcm.Characters.Last.Next Like "#" Then
rDcm.HighlightColorIndex = wdBrightGreen
End If
Wend
End With
Next
End Sub
Then delete the such highlighted text.
Which rises the question,
is there an otherwise not used highlighting in the doc?
Black, I think, might be a 999999:1 chance.
I've never heard of someone,
highlighting text in black.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.