3

How to extract text using regex in vb6

Dim MyText As String

MyText = "anything [*]textToExtract[*] anything"

Result Should Be :

textToExtract

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
faressoft
  • 19,053
  • 44
  • 104
  • 146

1 Answers1

6
Sub test()
    Dim re As RegExp, m As MatchCollection
    Set re = New RegExp
    Dim MyText As String, extractedText As String
    MyText = "anything textToExtract anything"

    re.Pattern = "anything (.*) anything"
    Set m = re.Execute(MyText)
    extractedText = m(0).SubMatches(0)

End Sub
Doc Brown
  • 19,739
  • 7
  • 52
  • 88