javascript - I don't understand the regex of this short answer, please explain it.
某草草
某草草 2017-05-19 10:40:46
0
2
416
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

某草草
某草草

reply all(2)
大家讲道理

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

// 因为[^...]代表匹配除过...代表的字符以外的所有字符,所以当然换行符也可以匹配了。
大家讲道理

Here is a series of explanations on regular expression related syntax. Regular expression front-end user manual | louis blog
Here is the directory structure:

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template