Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-03-2012, 06:46 PM
tinfanide tinfanide is offline VBScript.RegExp: exclude a particular word Windows 7 64bit VBScript.RegExp: exclude a particular word Office 2010 32bit
Expert
VBScript.RegExp: exclude a particular word
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default VBScript.RegExp: exclude a particular word

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.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
.doc Suddenly Changed to .vbe (VBScript Encoded Script File) emes Word 2 04-24-2012 05:07 PM
VBScript.RegExp: exclude a particular word WORD: Rtf and search-replace (regexp/fonts) seteshpl Word 1 09-06-2011 01:35 AM
Edit spell check dic to exclude words? franklekens Word 1 07-03-2010 09:57 AM
VbScript to Print a .pdf DaveB Excel 2 03-07-2009 12:36 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:40 AM.


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