A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/RegExp/multiline below:

multiline · WebPlatform Docs

multiline Summary

Returns a Boolean value indicating the state of the multiline flag ( m ) used with a regular expression. Default is false. Read-only.

Syntax
rgExp.multiline
Examples

The following example illustrates the behavior of the multiline property. If you pass “m” in to the function shown below, the word “while” is replaced with the word "and". This is because with the multiline flag is set and the word “while” occurs at the beginning of the line after a newline character. The multiline flag allows the search to be performed on multiline strings.

function RegExpMultilineDemo(flag){
    
    

    
    if (flag.match(/[^gim]/))
       {
       return ("Flag specified is not valid");
       }


    
    var ss = "The man hit the ball with the bat ";
    ss += "\nwhile the fielder caught the ball with the glove.";

    
    var re = new RegExp("^while", flag);
    var r = ss.replace(re, "and");

    
    var s = "";
    s += "Result for multiline = " + re.multiline.toString();
    s += ": " + r;

    return(s);

 }

 sa = RegExpMultilineDemo("m");
 sb = RegExpMultilineDemo("");
 document.write (sa + "<br />" + sb);
Remarks

The required rgExp argument is an instance of the RegExp object

The multiline property 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.

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".

See also Other articles Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4