
Originally Posted by
Radjesh Klauke
heya kevin. Thanks for the info. The issue here is that i only want to return (when we take your example) "line 5, position 4". The rest is not really interesting for me.
Well I am sure this could be done in Regex but here is a brute force method. Mocked represents our exception message. Yes this can be optimized in string functionality, I did this fast and it works.
Code:
Dim Mocked As String = "The 'wrong' start tag on line 5 position 4 does not match the end tag of 'test'. Line 8, position 3."
If Mocked.ToLower.Contains("line") AndAlso Mocked.ToLower.Contains("position") AndAlso Mocked.ToLower.Contains("does") Then
Dim Index As Integer = Mocked.ToLower.IndexOf("line") + 4
Dim Temp As String = Mocked.Substring(Index).TrimStart
Index = Temp.ToLower.IndexOf("position")
Console.WriteLine("Line index is " & Temp.Substring(0, Index))
Temp = Temp.Substring(Index)
Temp = Temp.Replace("position", "").TrimStart
Index = Temp.ToLower.IndexOf("does")
Console.WriteLine("Postion is " & Temp.Substring(0, Index))
End If