-
-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow matching substrings instead of patterns #1035
Comments
The current implementation of
Removing the code you've mentioned will have no effect on the current behavior (aside from making the type checker angry).
The reason we convert strings to Supporting strings without the need for escape sequences is a good idea but it will require more work than removing the mentioned lines of code. The current algorithm will have to be adapted to work with strings. |
Yes, you are right. I forgot that |
I have to admit motion-canvas is amazing though. |
Description
Currently, the
Code.findAllRanges
method does not match an exact substring in aCode
object. Instead, it unnecessarily creates aRegExp
object. If thefindAllCodeRanges
function can take aRegExp
object as an argument, why should it have to convert astring
toRegExp
?Solution
I could not find any existing function that matched a substring in the docs, so I am suggesting a quick change to remove some code from the
findAllCodeRanges
function inpackages/2d/src/lib/code/CodeRange.ts
.This means we can use
code().findFirstRange('n * (n + 1) / 2')
instead of typing out so many backslashes like this:code().findFirstRange('n \\* \\(n \\+ 1\\) \\/ 2')
. It is probably better practice to use aRegExp
constructor instead of implicitly converting astring
into aRegExp
.The text was updated successfully, but these errors were encountered: