Your parameters are the wrong way round - the first parameter is the string to test, and the second parameter is the regular expression to use:
Regex.IsMatch(myString, ".* My name is XYZ")
To retrieve the details of the match, use
the Match
method[
^], which returns
a Match
object[
^]. You'll also need to wrap the section you want to retrieve in a group:
(.*)
Dim myString As String = "Hi! My name is XYZ"
Dim match As Match = Regex.Match(myString, "(.*) My name is XYZ")
If match.Success Then
Dim matchedPart As String = match.Groups(1).Value
...
End If
Regular Expression Language - Quick Reference[
^]