Remove characters and retain only numbers from string

Something missing in your blocks (or something added)

image

Got it !! Tx !!

But there must be a way of RETAINING the numbers, using a NUMBER filter instead of REMOVING alphabets using a alphabet filter. Coz in case there is a special character ??
The list of combinations is endless. So instead of REMOVING THE UNWANTED, KEEP THE WANTED !

It is easier to avoid your data pollution upstream than to try to clean it up downstream.
Your data should have been set up as:

  • Cigarette (Rs)
  • 2000

This sample app shows how much easier this organization makes life for you ...

I am maintaining a record of daily expenses

Home Screen

Add Data

Add More Data

View Details

It was an after thought, in case there is a wrong entry or a double entry, and user desires to REMOVE a record, then the record shud get DELETED, and amount added to TOTAL shud also get reduced.

Yes, you could approach things the other ways around, instead of removing the letters, just keep the numbers (and/or any other characters you may want to include). Create a list of the numbers.

Here are the blocks (draggable) to do it with the numbers:

1 Like

can you share that project with us

Here are the blocks (draggable) !!

2 Likes

Please share the project with me :sob: :sneezing_face:

1 Like

Yes, you can just drag&drop to blocks editor.

1 Like

you mean the image can be a block

2 Likes

Wow, this is like a magic :star_struck: :heart_eyes:

2 Likes

No one ever saw this block?

image

2 Likes

Greetings all,
As the MIT App Inventor Ed Team we were working on a Voice Calculator project and in the Japanese version of the project one runs into a problem as there are no spaces between the numbers as Prof. Yamamoto's post discusses here:

We ran into a similar problem in the Chinese version of the project also and there is a discussion in the App Inventor team whether adding an extractNumbers text block to App Inventor would make sense. It is wonderful coincidence that the community is also discussing this today thanks to Anup_Ludra. We will let you know what is the outcome of this discussion hopefully in a few weeks.
Please note that Prof Yamamoto already suggests a great solution

using Regular Expressions using Kevin Ku's extension: https://community.thunkable.com/t/regular-expression-extension/3657
This extension should be importable to App Inventor by changing the file name a bit to: cnkevinkunRegEx.aix

1 Like

Oh, that is the perfect solution so far. I never use regex enough. I find it a little confusing, but is very powerful.

Is Number block is OK until the OP asks for a decimal point or a space to be included :wink:
(regex can probably be manipulated to include these....)

1 Like

You are right. In that case we can check FIRST for the point as an exception to the rule, advance to the next position and continue with the normal numbers check.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.