Open In App

JavaScript RegExp multiline Property

Improve
Improve
Like Article
Like
Save
Share
Report

The multiline Property property in Javascript is used to specify whether the “m” modifier is set or not. If the “m” modifier is set than this property returns true else false.

Syntax:

RegexObj.multiline

Return Value: It returns true if m modifier is set, else false. 

Example 1: This example checks if the regular expression contains m Modifier or not. 

Javascript




function geek() {
    let regex = new RegExp('foo', 'm');
    console.log(regex.multiline);
}
geek()


Output

true

Example 2: This example checks if the regular expression contains m Modifier or not. 

Javascript




function geek() {
    let regex = /[a-d]/;
    let str =
        "GeeksforGeeks\n" +
        "is the computer\n" +
        "science portal for geeks.";
 
    if (regex.multiline) {
        console.log("m Modifier is present");
    } else {
        console.log("m Modifier is absent.");
    }
}
geek()


Output

m Modifier is absent.

Supported Browsers: The browsers supported by multiline Property are listed below:

  • Google Chrome
  • Apple Safari
  • Mozilla Firefox
  • Opera
  • Internet Explorer

We have a complete list of Javascript RegExp expressions, to check those please go through this JavaScript RegExp Reference article.


Last Updated : 30 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads