Replace something with something in string

A feature I’d like to see in Hopscotch is:

A block to replace a part of a string with something else.
Preferably you’d be able to put a regular expression in the replace area.

I’d use it for this type of project:

Projects where I want to have a keyboard with new lines or a different looking keyboard, reversing text, working hopscotch editors in hopscotch

Here are some examples of Hopscotch code that could be improved if we had this:

Adding 1 leading zero to all 14s in a string

Here is an example design I’ve made:

Screen Shot 2020-05-28 at 1.23.40 PM

I’ve seen something similar in another programming languages, it looks like this:

https://www.w3schools.com/jsref/jsref_replace.asp

16 Likes

I second that


Nice block rendering page

5 Likes

I third

3 Likes

Definitely better than the ones I made

6 Likes

Imagine if this supported regular expressions :o

5 Likes

Having both a match and a replace block that supported regex would be a ‘game changer’ for advanced users! Think off all the data that could be encoded/decoded, and yet beginners could use the blocks simplistically too.

7 Likes

Interesting idea

This should be possible, i think, but a tad bit more complicated

1 Like

Why more complicated? What else would you want?

2 Likes

whoop used the wrong words

should = is

1 Like

This is an amazing idea.
I’ve seen this in the shortcuts app.

3 Likes
2 Likes

whoop forgot to remove words

be =

1 Like

How is it currently possible? You can tell if it will replace something with the mactehs block, you can maybe find out where it is, but you can’t actually replace it.

2 Likes

Manually

Yo I was gonna mention that today.
I found an epic Regex Git the other day, and I also learned of the existence of Swift Package Manager. Apps away.

3 Likes

:man_facepalming:t4:

1 Like