You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 9-regular-expressions/01-regexp-introduction/article.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -65,18 +65,18 @@ From here on the color scheme is:
65
65
66
66
67
67
````smart header="When to use `new RegExp`?"
68
-
Normally we use the short syntax `/.../`. But it does not allow any variable insertions, so we must know the exact regexp at the time of writing the code.
68
+
Normally we use the short syntax `/.../`. But it does not support variable insertions`${...}`.
69
69
70
-
On the other hand, `new RegExp` allows to construct a pattern dynamically from a string.
70
+
On the other hand, `new RegExp` allows to construct a pattern dynamically from a string, so it's more flexible.
71
71
72
-
So we can figure out what we need to search and create `new RegExp` from it:
72
+
Here's an example of a dynamically generated regexp:
73
73
74
74
```js run
75
-
letsearch=prompt("What you want to search?", "love");
76
-
let regexp =newRegExp(search);
75
+
lettag=prompt("Which tag you want to search?", "h2");
0 commit comments