Extract numbers from string

Hi guys , how can i extract only the numbers from a text string?

String before: "Ab1c2d3"
String after: “123”

String before: "Hello20World40"
String after: “2040”

1 Like

what about writing your own procedure?
use a for loop, some text blocks and the is a number block to check for numbers
see the documentation http://appinventor.mit.edu/explore/ai2/support/blocks.html


A very good way to learn App Inventor is to read the free Inventor’s Manual here in the AI2 free online eBook http://www.appinventor.org/book2 … the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Ok, i made it… this is the screenshot of the blocks i used

the do it result is 1214

if you want you can include this in your tutorials @Taifun


the most important thing is that the solution works…

as small suggestion, you might want to replace the global variable by a local variable
also the = and true blocks are obsolete…
it’s sufficient to have an if statement like this if true or if false.



The Global variable “Result” won’t work here if declared local, whereas the global variable “Text” can be declared as “Input” in this “Procedure Block” by tapping on the “Setting” icon on the top left corner of this procedure block.

Ahah this thread is 2 years old, in these 2 year i’ve improved a lot :rofl:
Btw thank you, this could be helpful for someone else.

1 Like

hehe i was just searching throughout so did not see the time it was created