Merge pull request #2261 from wam/change-var-to-let-in-regexp-sticky-section
Change `var` to `let` in 7.16 regexp-sticky
This commit is contained in:
commit
21d44a0590
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.
|
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.
|
- 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?**
|
**So, how to search for a regexp exactly at the given position?**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue