How do I retrieve a string that matches the regular expression of a VBA without postreading?

Asked 4 months ago, Updated 4 months ago, 10 views

I have a question about regular expressions in vba. I looked it up on vba and found that it doesn't read afterwards.
Could you tell me how to avoid reading after matching only the characters in parentheses?

regular-expression vba

2022-09-30 14:26

1 Answers

SubMatches can be taken out by grouping using parentheses such as (.*?).

Sub button 1_Click()
    Dimre As RegExp
    Set = New RegExp
    Set matches=re.Execute("hoge[fuga]piyo")
    MsgBox matches.Item(0).SubMatches(0)'"fuga" appears.
End Sub


Use regular expressions in VBA (RegExp object method)

2022-09-30 14:26

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.