Created
November 19, 2015 11:43
-
-
Save Teino1978-Corp/70dceda7f1936c6e4a22 to your computer and use it in GitHub Desktop.
GET_STRING_BETWEEN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim result = Regex.Matches(src, "\(([^()]*)\)").Cast(Of Match)().Select(Function(x) x.Groups(1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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