Untitled Snippet

Send Snippet To: Save this snippet to Code Collector Pro -- view all surfrgeek's snippets
language: Other
license: Other

Code for Snippet:

                
Option Explicit
 
 
'**************************************************
'MATCH & EXTRACT  Examples using the EXECUTE method
'**************************************************
 
Public Sub Match_and_Extract_1()
    'declare a RegExp type
    Dim Reg As RegExp
 
    'declare other variables
    Dim strOrg As String, strMatches As Object, strMatch As Object
    Dim valid As Boolean
 
 
    'create a new RegExp object
    Set Reg = New RegExp
 
    'set the desired pattern to match in the RegExp object
    'Reg.Pattern = "[0-9][0-9][0-9][0-9][0-9][0-9])"
    Reg.Pattern = "\d+"
    Reg.Global = True
    Reg.IgnoreCase = True
 
    'set string to be matched and replaced
    'strOrg = "qwerty123456uiops"
    strOrg = "1qw2er3ty4uio5ps"
 
    'conduct matching & extracting
     Set strMatches = Reg.Execute(strOrg)    'Use Execute method of the object
 
    MsgBox strMatches.Count
 
    For Each strMatch In strMatches
        MsgBox strMatch
    Next
 
 
End Sub
 
comments powered by Disqus

Info

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 25
Date Added: 2017-09-09 19:07:49
Last Modified: 2017-09-09 14:08:04

Web Analytics