Change var
to let
in 7.16 regexp-sticky
Commit 10d1b1f25
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`.
This commit is contained in:
parent
dccca58f26
commit
ec81513954
1 changed files with 1 additions and 1 deletions
|
@ -13,7 +13,7 @@ E.g. we have a code string `subject:let varName = "value"`, and we need to read
|
|||
|
||||
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.
|
||||
|
||||
- A call to `str.match(/\w+/)` will find only the first word in the line (`var`). That's not it.
|
||||
- A call to `str.match(/\w+/)` will find only the first word in the line (`let`). That's not it.
|
||||
- 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.
|
||||
|
||||
**So, how to search for a regexp exactly at the given position?**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue