This is not just an Excel VBA question, anyway, I'd post it here for help:
Code:
Dim str6 As String
str6 = "cat and dog"
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.Pattern = "\b[^cat]{3}\b"
For Each oMatch In .Execute(str6)
Debug.Print oMatch
Next oMatch
End With
''' output
''' dog
I want to have any words except "cat" but the above codes also exclude the word "and". How can I do a pattern that excludes a particular word instead of
Code:
.pattern = "[^cat]"
which just shows me
Quote:
(space)
n
d
(space)
d
o
g
|
in the console.