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

Asked 2 years ago, Updated 2 years ago, 76 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
    re.Pattern="[(.*?)]" 
    Set matches=re.Execute("hoge[fuga]piyo")
    MsgBox matches.Item(0).SubMatches(0)'"fuga" appears.
End Sub

References

Use regular expressions in VBA (RegExp object method)


2022-09-30 14:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.