If you just want to extract the coordinates from your example string, this sub might do it:
Sub SplitPoint(P As String) As Double()
Dim Temp() As String = Regex.Split("(\(|\ +|\))", P) 'separators are "(", ")", and one or more contiguous spaces " "
If Temp.Length >= 2 Then
If IsNumber(Temp(1)) And IsNumber(Temp(2)) Then
Return Array As Double(Temp(1), Temp(2))
End If
End If
Return Array As Double()
End Sub
It returns an array of numeric values (but is easy to strip back to strings) with either:
- two elements, if the string is valid, or
- zero elements (ie empty array), if the string is not valid.
You can test it with this:
Dim TestPoints() As String = Array As String( _
"POINT(2550012.664 196252.944)", _
"POINT(2550012 196252)", _
"POINX(2550012.664 196252.944)", _
"PT(2550012.664 196252.944)", _
"P O I N T(123 456)", _
"(2550012.664 196252.944)" _
)
For Each Point As String In TestPoints
Dim RA() As Double = SplitPoint(Point)
If RA.Length = 2 Then
Log("coordinates are " & RA(0) & " and " & RA(1))
Else
Log("unable to parse point """ & Point & """")
End If
Next
Waiting for debugger to connect...
Program started.
coordinates are 2550012.664 and 196252.944
coordinates are 2550012 and 196252
coordinates are 2550012.664 and 196252.944
coordinates are 2550012.664 and 196252.944
unable to parse point "P O I N T(123 456)"
coordinates are 2550012.664 and 196252.944