This commit is contained in:
Ilya Kantor 2019-10-10 11:07:05 +03:00
parent a57edc1036
commit aee2bd2ca6
2 changed files with 12 additions and 1 deletions

View file

@ -12,7 +12,7 @@ Scripts are provided and executed as plain text. They don't need special prepara
In this aspect, JavaScript is very different from another language called [Java](https://en.wikipedia.org/wiki/Java_(programming_language)). In this aspect, JavaScript is very different from another language called [Java](https://en.wikipedia.org/wiki/Java_(programming_language)).
```smart header="Why <u>Java</u>Script?" ```smart header="Why is it called <u>Java</u>Script?"
When JavaScript was created, it initially had another name: "LiveScript". But Java was very popular at that time, so it was decided that positioning a new language as a "younger brother" of Java would help. When JavaScript was created, it initially had another name: "LiveScript". But Java was very popular at that time, so it was decided that positioning a new language as a "younger brother" of Java would help.
But as it evolved, JavaScript became a fully independent language with its own specification called [ECMAScript](http://en.wikipedia.org/wiki/ECMAScript), and now it has no relation to Java at all. But as it evolved, JavaScript became a fully independent language with its own specification called [ECMAScript](http://en.wikipedia.org/wiki/ECMAScript), and now it has no relation to Java at all.

View file

@ -144,6 +144,17 @@ That's what flag `pattern:s` does. If a regexp has it, then a dot `pattern:.` ma
alert( "A\nB".match(/A.B/s) ); // A\nB (match!) alert( "A\nB".match(/A.B/s) ); // A\nB (match!)
``` ```
````warn header="Not supported in Firefox, IE, Edge"
Check <https://caniuse.com/#search=dotall> for the most recent state of support.
Luckily, there's an alternative. We can use a regexp like `pattern:[\s\S]` to match "any character".
```js run
alert( "A\nB".match(/A[\s\S]B/) ); // A\nB (match!)
```
This works everywhere.
````
````warn header="Pay attention to spaces" ````warn header="Pay attention to spaces"
Usually we pay little attention to spaces. For us strings `subject:1-5` and `subject:1 - 5` are nearly identical. Usually we pay little attention to spaces. For us strings `subject:1-5` and `subject:1 - 5` are nearly identical.