-
Notifications
You must be signed in to change notification settings - Fork 302
strings: Add splitJSON and matchRegexJSON #2306
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
base: master
Are you sure you want to change the base?
Conversation
Added modified versions of split and matchRegex that return an array instead of a specific item, which can be useful in more complex projects.
|
Converted to draft so I could fix some things |
|
There we go |
|
To be honest, it's kind of weird that these weren't already in the extension. It's no stranger to more complex features like regexes, which Scratch's target audience wouldn't have much of a grasp on. There are, in fact, genuine use cases for these new blocks—I made these changes to benefit one of my own projects with hopes of making a script much faster than using loops and variables. |
|
Yeah it's safe to say no one's gonna review this pr for a while |
|
Alright wish granted |
Brackets-Coder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax looks fine I guess, nothing jumps out just a quick skim
For the split JSON block, is the intended functionality to leave blank elements where the split was or remove everything except the split
e.g., "apple" split by "p" returns ["a","","le"], did you mean to remove the blank middle item?
Another concern I have—do the "regex" inputs accept RegEx blocks from the RegEx extension? Those return strings, so you might want to find ways to parse the strings back into actual JS regex
|
I just copied the existing (I also have no idea how regexes work sooooo time to go learn stuff ig) |
|
|
Wait so if the functionality is the same what actually changed? |
I only changed it so it returned the whole (stringified) array instead of a single item. |


Added modified versions of
splitandmatchRegexthat both return an array instead of a specific item, which can be useful in more complex projects. I also movedtestRegexso all of the match blocks could be together in the palette.Pretty quick, so there isn't that much polish. It was mostly an easy copy-and-paste job and things are still left in.