用於指定 ^ 和 $ 錨點是否符合每行開始和結束的布林值 (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" 開頭。