Thread: RegExp:
View Single Post
 
Old 06-08-2014, 08:52 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default RegExp:

Code:
Sub regexp()

Dim s(3) As String

s(0) = "recent photo"
s(1) = "photo"
s(2) = "recentphoto"

With CreateObject("vbscript.regexp")
    .Pattern = "(recent ){0,1}photo"
    .IgnoreCase = True
    .Global = True
    
    For x = 0 To 2
        For Each oMatch In .Execute(s(x))
            MsgBox oMatch
        Next oMatch
    Next
    
End With

End Sub
Eventually, I want these combinations only:
"photo"
"recent photo"

but don't want:
"recentphoto"


Thank you.
Reply With Quote