This commit is contained in:
Ilya Kantor 2019-09-06 16:48:59 +03:00
parent 681cae4b6a
commit 4232a53219
10 changed files with 315 additions and 342 deletions

View file

@ -56,9 +56,9 @@ If we are creating a regular expression with `new RegExp`, then we don't have to
For instance, consider this:
```js run
let reg = new RegExp("\d\.\d");
let regexp = new RegExp("\d\.\d");
alert( "Chapter 5.1".match(reg) ); // null
alert( "Chapter 5.1".match(regexp) ); // null
```
The similar search in one of previous examples worked with `pattern:/\d\.\d/`, but `new RegExp("\d\.\d")` doesn't work, why?
@ -87,9 +87,9 @@ let regStr = "\\d\\.\\d";
*/!*
alert(regStr); // \d\.\d (correct now)
let reg = new RegExp(regStr);
let regexp = new RegExp(regStr);
alert( "Chapter 5.1".match(reg) ); // 5.1
alert( "Chapter 5.1".match(regexp) ); // 5.1
```
## Summary