Thread: [Solved] Find Challenge
View Single Post
 
Old 01-06-2025, 04:00 PM
batman1 batman1 is offline Windows 11 Office 2013
Advanced Beginner
 
Join Date: Jan 2025
Posts: 57
batman1 is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
Batman1,


English not being your first language, it is understandable that things aren't always are clearly expressed or understood and that is a two way street.

Not to dispute you, but I would like to see a RegEx pattern that returns the same result as the Find\Do While Execute in ScatchMacroC. ScratchMacroC is simple to me because and am much more familiar with the Word Find method and range object than I am with RegEx. I have no doubt that with the right RegEx pattern that processing the data would be more efficient.
I'm curious about the simple code from Find.

Code from Regex e.g.
Code:
Sub test()
Dim RegEx As Object, Matches As Object, Match As Object
    Set RegEx = CreateObject("VBScript.RegExp")
    With RegEx
        .Global = True
        .Pattern ="(?=\d{0,3}2)\d{4,5}"
    End With
    Set Matches = RegEx.Execute(ActiveDocument.Range.text)
    For Each Match In Matches
        Debug.Print Match.Value
    Next
End Sub
OR .Pattern = "(?=(\d){0,3}2)\d{4,5}"
Reply With Quote