IgnoreCase Property

Boolean value (True or False) that specifies whether the regular expression should be case-insensitive.

Note:

Default value is False.

Set Property Usage:

Syntax: 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

The Test method checks if the pattern matches the string, returning True because it finds AppLe in the text, even though they are capitalized differently. IgnoreCase = True setting helps to search the string case insensitively. If IgnoreCase = False, Test method would have searched strictly for string apple and resulted False, as apple is not available in inputString.