Skip to content

Commit e09706a

Browse files
committed
Change var to let in 7.16 regexp-sticky
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`.
1 parent 9543c73 commit e09706a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

16-regexp-sticky/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ E.g. we have a code string `subject:let varName = "value"`, and we need to read
1313

1414
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.
1515

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.
1717
- 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.
1818

1919
**So, how to search for a regexp exactly at the given position?**

0 commit comments

Comments
 (0)