dotAll option or /s makes dot (.) character match any character with newlines as well. Without this flag, the dot (.) character match any character but not the newlines such as \n. Check and uncheck the 's' option below to see the difference.
one two three four five
match | position |
---|---|
o | 0 |
n | 1 |
e | 2 |
3 | |
t | 4 |
w | 5 |
o | 6 |
7 | |
8 | |
9 | |
t | 10 |
h | 11 |
r | 12 |
e | 13 |
e | 14 |
15 | |
f | 16 |
o | 17 |
u | 18 |
r | 19 |
20 | |
21 | |
f | 22 |
i | 23 |
v | 24 |
e | 25 |
Multiline option makes ^ and $ anchors work in every line in a multiline string input. If this option is not used, the entire multiline input will be considered as a single line of text with embedded newline character. In such case, ^ and $ will be applied only once at the begin and end of the multiline text respectively.
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
match | position | $1 |
---|---|---|
The | 0 | T |
own | 12 | |
the | 31 | t |
the | 76 | t |
own | 102 | |
own | 147 |
Javascript Regular ExpreSSionS
match | position |
---|---|
s | 4 |
S | 24 |
S | 25 |
S | 29 |