Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-20-2018, 08:06 AM
davidlooney davidlooney is offline Regular Expressions Windows 7 32bit Regular Expressions Office 2016
Novice
Regular Expressions
 
Join Date: Jul 2018
Posts: 1
davidlooney is on a distinguished road
Default Regular Expressions

I’m trying to write a regular expression where the string matches “_Clauses” OR “_OL” but NOT “_Word”. Can anyone help? The OR part works, the NOT doesn’t.

Dim regex As Object, str As String
Set regex = CreateObject("VBScript.RegExp")

With regex
.Pattern = "_Clauses|_OL[^_Word]"
.Global = True
End With

For Each ws In ActiveWorkbook.Worksheets
str = ws.Name


Debug.Print regex.Test(str)
Next ws
Reply With Quote
  #2  
Old 08-20-2018, 08:23 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Regular Expressions Windows 7 64bit Regular Expressions Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,771
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Hi and welcome
please wrap code with code tags (#button) Thanks
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions regular expressions in footnotes loes Word 3 09-04-2019 07:52 AM
Regular expressions and field codes Cosmo Word VBA 5 04-20-2018 04:10 PM
Word Regular Expressions: zero or more occurences? tinfanide Word 6 09-16-2015 03:13 PM
regular expressions for empty lines eNGiNe Word 1 01-21-2013 06:38 AM
Regular Expressions Regular Expressions: [!0-9] does not work??? tinfanide Excel Programming 4 05-30-2012 04:09 AM

Other Forums: Access Forums

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


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