The code below does not work properly. I am using Microsoft Access VBA. When the code works properly, the variable
strAnswer = "Line 4:Line5" with the nonprinting characters preserved.
I am using the wrong pattern. Also, I am not sure how to assign the regex result to a string.
I would appreciate your help.
Public Sub ExtractString() Dim str As String str = "Line 1." & vbCrLf str = str & "Line 2 :" & vbCrLf str = str & "Line 3 :" & vbCrLf str = str & "Line 4:" & vbCrLf str = str & "Line 5:" & vbCrLf str = str & "Line 6:" & vbCrLf str = str & "The End" Dim reg As New regExp reg.Pattern = "Line 4:\r(.*?)\rLine 6:" reg.Global = True reg.IgnoreCase = True Dim Matches As MatchCollection Set Matches = reg.Execute(str) Dim strAnswer As String strAnswer = reg.Execute(str)End Sub
Much appreciated. I get lots of data that is computer generated. The data is always in the same place, so now I can develop a tool to sift out the data that I need.
pls try
Open in new window
Regards