I have a string like so: asdf text:a123a)! testing. I would like to get this string and extract this string: a123a)!.
I'm trying to do it like so:
If TextBox.Text.Trim.ToUpper.Contains("TEXT:") Then
Dim SearchStringFilter As String = TextBox.Text.Trim
Dim FilterString As Match = Regex.Match(SearchStringFilter, "text:([A-Za-z0-9\-])", RegexOptions.IgnoreCase)
If FilterString .Success Then
Dim SubFilterString As String = StateFilterString.Value.ToUpper.Replace("TEST:", "")
MessageBox.Show(SubFilterString)
End If
End If
However, this code does not seem to be working correctly. It will only output "1". Can anyone help?
Contains, why not useContains? Regex is for pattern matching and you are looking for an exact string.