var s = 'Please yes\nmake my day!';
s.match(/yes[^]*day/);
// Returns ["yes\nmake my day"]
Why? Mainly because I don’t understand the grammar at the middle point
大家讲道理2017-05-19 10:42:46
It should be to solve the problem of matching all characters including newlines.
. ===
[^rn]
(dot, decimal point) matches any single character, except carriage return r line feed n characters: n r u2028 or u2029.
In the character set, dot ( . ) loses its special meaning and matches a literal dot ( . ).
It should be noted that the m multiline flag does not change the behavior of the period. So to match a character set across multiple lines, use [^] > (of course you don't intend to use it in older versions of IE), which will match any character, including newlines.
For example, /.y/ matches "my" and "ay" in "yes make my day", but not "yes".
>> var s = 'Please yes make my day!';
>> s.match(/yes.*day/);
Array [ "yesmake my day" ]
// 因为[^...]代表匹配除过...代表的字符以外的所有字符,所以当然换行符也可以匹配了。
大家讲道理2017-05-19 10:42:46
Here is a series of explanations on regular expression related syntax. Regular expression front-end user manual | louis blog
Here is the directory structure: