devxlogo

Use GetBetween to Parse a String Between Two Strings

Use GetBetween to Parse a String Between Two Strings

This tips shows how to use GetBetween to parse and extract a string between two strings. GetBetween returns the extracted string, if found.

Public Function GetBetween(ByRef sSearch As String, ByRef sStart As String, ByRef sStop As String, _                                                    Optional ByRef lSearch As Long = 1) As String    lSearch = InStr(lSearch, sSearch, sStart)    If lSearch > 0 Then        lSearch = lSearch + Len(sStart)        Dim lTemp As Long        lTemp = InStr(lSearch, sSearch, sStop)        If lTemp > lSearch Then            GetBetween = Mid$(sSearch, lSearch, lTemp - lSearch)        End If    End IfEnd Function
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist