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
Commit 10d1b1f added a hint about which word would be found by
a certain regexp:
"A call to str.match(/\w+/) will find only the first word in the line
(var). That’s not it."
Unfortunately the result is incorrect: the regexp would find `let`, not
`var`.
Updating the hint should resolve any confusion. The example has been
tested in the console to ensure that the regexp does indeed return
`let`.
Copy file name to clipboardExpand all lines: 16-regexp-sticky/article.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ E.g. we have a code string `subject:let varName = "value"`, and we need to read
13
13
14
14
We'll look for variable name using regexp `pattern:\w+`. Actually, JavaScript variable names need a bit more complex regexp for accurate matching, but here it doesn't matter.
15
15
16
-
- A call to `str.match(/\w+/)` will find only the first word in the line (`var`). That's not it.
16
+
- A call to `str.match(/\w+/)` will find only the first word in the line (`let`). That's not it.
17
17
- We can add the flag `pattern:g`. But then the call `str.match(/\w+/g)` will look for all words in the text, while we need one word at position `4`. Again, not what we need.
18
18
19
19
**So, how to search for a regexp exactly at the given position?**
0 commit comments