Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Created November 19, 2015 11:43
Show Gist options
  • Save Teino1978-Corp/70dceda7f1936c6e4a22 to your computer and use it in GitHub Desktop.
Save Teino1978-Corp/70dceda7f1936c6e4a22 to your computer and use it in GitHub Desktop.
GET_STRING_BETWEEN
Function GET_STRING_BETWEEN(ByVal start As String, ByVal parent As String, ByVal [end] As String)
Dim output As String
output = parent.Substring(parent.IndexOf(start) _
, (parent.IndexOf([end]) _
- parent.IndexOf(start)) _
).Replace(start, "").Replace([end], "")
output = start & output & [end]
Return output
End Function
Dim result = Regex.Matches(src, "\(([^()]*)\)").Cast(Of Match)().Select(Function(x) x.Groups(1))
Dim src As String = "hello (string1) there how (string2) are you?"
Dim strs As New List(Of String)
Dim start As Integer = 0
Dim [end] As Integer = 0
While start < src.Length
start = src.IndexOf("("c, start)
If start <> -1 Then
[end] = src.IndexOf(")"c, start)
If [end] <> -1 Then
Dim subStr As String = src.Substring(start + 1, [end] - start - 1)
If Not subStr.StartsWith("(") Then strs.Add(src.Substring(start + 1, [end] - start - 1))
End If
Else
Exit While
End If
start += 1 ' Increment start to skip to next (
End While
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment