Dim strPath() As String = {"C:\fail\fair.text", "asdfgh"} For i As Integer = 0 To strPath.Length - 1 If strPath(i).IndexOf(":") > -1 And strPath(i).IndexOf("\") > -1 And strPath(i).IndexOf(".") > -1 Then Console.WriteLine("パスです。 " & strPath(i)) Else Console.WriteLine("パスではありません。" & strPath(i)) End If Next
Dim strPath() As String = {"C:\fail\fair.text", "asdfgh"} Dim regex As New System.Text.RegularExpressions.Regex("[a-zA-Z]:\.*") For i As Integer = 0 To strPath.Length - 1 If (regex.IsMatch(strPath(i))) Then Console.WriteLine("パスです。 " & strPath(i)) Else Console.WriteLine("パスではありません。" & strPath(i)) End If Next