Thread: [Solved] Find Challenge
View Single Post
 
Old 01-06-2025, 02:55 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
This post is a continuation of a discuss that started here:
https://www.msofficeforums.com/word-...x-pattern.html

1. I would not consider "13452234567" to be a number consisting of 4 or 5 digits. I consider that to be a number consisting of 11 digits and my original reply treated it as such.
I don't know English, I used google translate, so the sentences are not precise. "13452234567" is the input data - STRING, only the result should be a number.
Quote:

2. There was nothing in my original reply that implied that the 4 or 5 digit numbers "had" to be a word.
In post #31 I saw .text = "<[0-9]{4;5}>". I think vivka saw it too, that's why he repeated it .text = "<[0-9]{4,5}>" in post #33. But since I didn't take a screenshot, let's say I saw it wrong.

Quote:

3. Now if one wishes to find 34522 embedded in a larger sequence of numbers that is certainly possible.
For clarity, let's now have a different, second task and we want to find 34522 in "13452234567"

Quote:

4. If our goal is to find 34522 in 13452234567, then do we also want to A) find 45223, 52234, 22345 and 23456 which are also number segments embedded in the larger 11 digit string or B) Find the first match in the sequence and escape or C) Continue looking for matches in even longer strings e.g., "1345223456712345" and return both 34522 and 67123
Let's assume there is a code
Code:
Sub test1()
Dim oRng As Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
        .text = "aga"
        Do While .Execute
            Debug.Print oRng.text
        Loop
    End With
End Sub
and there is only 1 word in the document: Agaga

We will get the result = "Aga", there is no second result "aga". So after finding one result, further search will occur after this result.

Similarly, in my task, further search will occur after the current result, which means it should be C - results = 34522 and 67123
Reply With Quote