9

my regex match in VBA (WORD) only gives one result.

I created this function

Function RE6(strData As String) As String

    Dim RE As Object, REMatches As Object
    Set RE = CreateObject("vbscript.regexp")
    With RE
        .MultiLine = False
        .Global = False
        .IgnoreCase = True
        .Pattern = "\[substep [a-zA-Z]\](.*?); {1}"
    End With

    Set REMatches = RE.Execute(strData)

    RE6 = ""


End Function

The problem here is that it only gives the first result. For example I got a string:

[step 1] title for substeps;  [substep a] step a; [substep b] step b; [substep c] step c; 

My result is:

[substep a] step a;

only 1 match, not the step b and c.

1 Answer 1

13

You need to set Global to True

http://msdn.microsoft.com/en-us/library/tdte5kwf%28v=vs.84%29

Sign up to request clarification or add additional context in comments.

1 Comment

oh my god is it that simple.. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.