Skip to content

Commit c498fc6

Browse files
adding the [^] pattern
1 parent 58205b3 commit c498fc6

File tree

1 file changed

+2
-0
lines changed
  • 9-regular-expressions/02-regexp-character-classes

1 file changed

+2
-0
lines changed

9-regular-expressions/02-regexp-character-classes/article.md

+2
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ alert( "A\nB".match(/A[\s\S]B/) ); // A\nB (match!)
156156
The pattern `pattern:[\s\S]` literally says: "a space character OR not a space character". In other words, "anything". We could use another pair of complementary classes, such as `pattern:[\d\D]`, that doesn't matter.
157157
158158
This trick works everywhere. Also we can use it if we don't want to set `pattern:s` flag, in cases when we want a regular "no-newline" dot too in the pattern.
159+
160+
Also worth mentioning is, besides `[\s\S]`, there is another regular expression that can match any character, which is `[^]` -- it means match any character except nothing, and that means to match any character without exception. `[^]` and `[\s\S]` are the two typical regular expressions to solve the missing of `s` flag problem.
159161
````
160162

161163
````warn header="Pay attention to spaces"

0 commit comments

Comments
 (0)