Single-line mode and multi-line mode of js

problem description

want to know the difference between single-line mode and multi-line mode in js?
can you give me some examples?

the environmental background of the problems and what methods you have tried

after consulting a lot of materials, the explanation is not very clear, but I still want to see it clearly through examples. Only the following article talks about it, but I still don"t quite understand
. I hope you guys can help explain
https://codeshelper.com/a/11.

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)


var text = "this has bean a short summer";
var regx = /(.)hort/g;

 if(regx.test(text)){
    alert(RegExp.input);//this has bean a short summer
    alert(RegExp.lastMatch);//short
    alert(RegExp.lastParen);//s
    alert(RegExp.leftContext);//this has bean a 
    alert(RegExp.rightContext);// summer
    alert(RegExp.multiline);//false
   }

what result do you expect? What is the error message actually seen?

alert (RegExp.multiline); / / false
this browser outputs false, and wants to know how to change the string text so that the browser can output true


var regx = /(.)hort/gm

difference between single-line mode and multiline mode
switch single-line mode affects metacharacters. Match: metacharacter "." when
single-line mode is turned on. Matches any character, including the newline character n. Metacharacter "." when
single-line mode is turned off. Matches any character that does not include the newline character n.

The

switch multiline mode affects the matching of metacharacters "^" and "$":
if multiline is false, then "^" matches the beginning of the string, while "$" matches the end of the string.
if multline is true, then "^" matches the position at the beginning of the string and the position after "n" or "r", while "$" matches the position at the end of the string and the position before "n" or "r". The
multiline pattern is to separate the string into multiple single-line patterns based on r or n to match whether
has the modifier m or not to decide whether to execute the multiline pattern.

< hr >

example

var s = "haha, hello!\nhaha, ni hao a!";
//"^" 
alert(s.replace(/^haha/g, "heihei"));//heihei, hello!\nhaha, ni hao a!
//"^"  "\n"
alert(s.replace(/^haha/gm, "heihei"));//heihei, hello!\nheihei, ni hao a!
< hr >

want to know how to change the string text so that the browser can output true

var text = 'this has bean a short summer';
var regx = /(.)hort/gm;

 if(regx.test(text)){
    
    alert(regx.multiline);//truem
 }

multiline is all properties of the instance of the RegExp object , not owned by the RegExp object.
you can take a look at the following link:
RegExp object

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39bc8-2c1c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39bc8-2c1c4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?