IgnoreCaseプロパティ

正規表現で大/小文字を区別しないかどうかを指定するブール値(TrueまたはFalse)。

Note:

デフォルト値はFalseです。

プロパティの使用方法の設定:

構文: Object.IgnoreCase= "<True/False>"

Dim regex, inputText
' Create a new RegExp object
Set regex = CreateObject("VBScript.RegExp")

' Set the pattern and ignore case
regex.Pattern = "apple"  ' Pattern to match the word 'apple'
regex.IgnoreCase = True  ' Ignore case when matching

' Input text
inputText = "I ate an AppLe today."
' Test if the pattern matches the input text
If regex.Test(inputText) Then
    'Match found Logic
Else
    'No match found Logic
End If

Testメソッドは、パターンが文字列と一致するかどうかをチェックし、Trueを戻します。これは、大文字と小文字が異なっていても、テキスト内でAppLeが検出されるためです。IgnoreCase = True設定は、大/小文字を区別せずに文字列の検索するのに役立ちます。IgnoreCase = Falseの場合、Testメソッドは文字列appleを厳密に検索し、結果はFalseになります。これは、appleinputStringで該当しないためです。