'Example Dim x As String = RegexBetween("Tea", "go")
Private Function RegexBetween(ByVal sw As String, ByVal ew As String) As String
Dim s As String = "SomeText Tea ฟหกด Someone love one Someone love two but i love one go to bed"
Dim r As New Regex(sw & "(.+?)" & ew)
Dim m As Match = r.Match(s)
If m.Success Then
Return m.Groups(1).ToString()
End If
Return "Not found"
End Function
Imports System.Text.RegularExpressions
'Example Dim x As String = RegexBetween("Tea", "go")
Private Function RegexBetween(ByVal sw As String, ByVal ew As String) As String
Dim s As String = "SomeText Tea ฟหกด Someone love one Someone love two but i love one go"
Dim r As New Regex(sw & "(.+?)" & ew)
Dim m As Match = r.Match(s)
If m.Success Then
Return m.Groups(1).ToString()
End If
Return "Not found"
End Function
Imports System.Text.RegularExpressions
Imports System.ComponentModel
Public Class Form1
Private Function RegexBetween(ByVal sw As String, ByVal ew As String, ByVal txtTextBox1_Text As String) As String
Dim s As String = txtTextBox1_Text
Dim r As New Regex(sw & "(.+?)" & ew)
Dim m As Match = r.Match(s)
If m.Success Then
Return m.Groups(1).ToString()
End If
Return "Not found"
End Function
Protected Sub btnGetBetweenText_Click(sender As Object, e As EventArgs) Handles btnGetBetweenText.Click
TextBox2.Text = RegexBetween("Tea", "go", TextBox1.Text)
End Sub
End Class