「VB.NET」IsMatchメソッドで末尾の文字列を指定する

2022年3月23日

書式
指定文字$
「$」を利用して末尾が特定文字を指定しています。

使用例
末尾が「ST」の文字を指定しています。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Imports System.Text
Imports System.Text.RegularExpressions
Module Module1
Sub Main()
'末尾の文字列$
Dim a As String = "ST$"
'True
Console.WriteLine(Regex.IsMatch("TST", a))
'False
Console.WriteLine(Regex.IsMatch("TET", a))
Console.ReadKey()
End Sub
End Module
Imports System.Text Imports System.Text.RegularExpressions Module Module1 Sub Main() '末尾の文字列$ Dim a As String = "ST$" 'True Console.WriteLine(Regex.IsMatch("TST", a)) 'False Console.WriteLine(Regex.IsMatch("TET", a)) Console.ReadKey() End Sub End Module
Imports System.Text
Imports System.Text.RegularExpressions

Module Module1

    Sub Main()
        '末尾の文字列$
        Dim a As String = "ST$"

        'True
        Console.WriteLine(Regex.IsMatch("TST", a))

        'False
        Console.WriteLine(Regex.IsMatch("TET", a))

        Console.ReadKey()
    End Sub

End Module

実行結果
True
False

VB.net

Posted by arkgame