Multilineプロパティ

^アンカーと$アンカーが各行の先頭と末尾に一致するかどうかを指定するブール値(TrueまたはFalse)。

Note:

デフォルト値はFalseです。

プロパティの使用方法:

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

例:

Dim regEx, inputStr, result
Set regEx = CreateObject("VBScript.RegExp")
' Enable multiline mode
regEx.Multiline = True
' Pattern to match the beginning of each line
regEx.Pattern = "^Hello"
regEx.IgnoreCase = True
' Input string with multiple lines
inputStr = "Hello, world!" & vbCrLf & "This is a test." & vbCrLf & "Hello again!"
' Find all lines that start with "Hello"
result = regEx.Test(inputStr)
If result Then
    'Logic Matches at the start of a line.
Else
    'Logic Does not match at the start of any line.
End If

Multilineが有効な場合、^と$の動作は異なっており、文字列全体ではなく各行の先頭と末尾に一致します。前述の例ではMultiline = Trueであるため、^Helloは"Hello, world!"および"Hello again!"と一致します(両方の行とも"Hello"で始まるため)。