Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression.
rgExp.multiline |
Arguments
- rgExp
-
Required. An instance of a Regular Expression object.
Remarks
The multiline property is read-only, and returns true if the multiline flag is set for a regular expression, and returns false if it is not. The multiline property is true if the regular expression object was created with the m flag. The default value is false.
If multiline is false, "^" matches the position at the beginning of a string, and "$" matches the position at the end of a string. If multiline is true, "^" matches the position at the beginning of a string as well as the position following a "\n" or "\r", and "$" matches the position at the end of a string and the position preceding "\n" or "\r".
Example
The following example illustrates the use of the multiline property.
В | Copy Code |
---|---|
function RegExpPropDemo(re : RegExp) { print("Regular expression: " + re); print("global: " + re.global); print("ignoreCase: " + re.ignoreCase); print("multiline: " + re.multiline); print(); }; // Some regular expression to test the function. var re1 : RegExp = new RegExp("the","i"); // Use the constructor. var re2 = /\w+/gm; // Use a literal. RegExpPropDemo(re1); RegExpPropDemo(re2); RegExpPropDemo(/^\s*$/im); |
The output of this program is:
В | Copy Code |
---|---|
Regular expression: /the/i global: false ignoreCase: true multiline: false Regular expression: /\w+/gm global: true ignoreCase: false multiline: true Regular expression: /^\s*$/im global: false ignoreCase: true multiline: true |