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:
Ilya Kantor 2020-11-10 12:06:47 +03:00 committed by GitHub
commit 21d44a0590
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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?**