cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver II
Resolver II

Formula to remove letters

Hi, just wondering if anyone knew a powerapps formula to remove letters from a string -

If the string contains numbers, spaces and letters. I want to export only the numbers and spaces.

e.g. one1 three3 two2 five5 = 1 3 2 5
I need this because it's gonna be part of a larger complicated function 😅

Please help 🙃

3 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Resolver III
Resolver III

Re: Formula to remove letters

You can try this magical formula 🙂 in text property of a label to see if it works: 

 

Trim(Concat(Split(InitialValue,""),If(IsBlankOrError(Value(Result)),"",Result)," "))

 

where

Initialvalue is your text.

View solution in original post

Highlighted
Resident Rockstar
Resident Rockstar

Re: Formula to remove letters

Assuming your string is in Label1, try this

 

Substitute ( Label1.Text, "[^0-9 ]+", "" )

 

my regex isnt the best but this may work?

Note: there's a deliberate space after the 9

View solution in original post

Highlighted
Resolver II
Resolver II

Re: Formula to remove letters

Hi @mdevaney ,

The solution I ended with was - Trim(Concat(Split(InitialValue,""),If(IsBlankOrError(Value(Result)) && !(Result = " "),"",Result),""))

I chose this out of the two solutions simply out of personal preference to fit toward my own coding style.

Both answers by @gabibalaban and @Eelman were equally helpful without my personal bias so I wouldn't know which to mark as a solution.

Kudos given and I'll mark this as the solution 👌

View solution in original post

11 REPLIES 11
Highlighted
Resolver III
Resolver III

Re: Formula to remove letters

You can try this magical formula 🙂 in text property of a label to see if it works: 

 

Trim(Concat(Split(InitialValue,""),If(IsBlankOrError(Value(Result)),"",Result)," "))

 

where

Initialvalue is your text.

View solution in original post

Highlighted
Resident Rockstar
Resident Rockstar

Re: Formula to remove letters

Assuming your string is in Label1, try this

 

Substitute ( Label1.Text, "[^0-9 ]+", "" )

 

my regex isnt the best but this may work?

Note: there's a deliberate space after the 9

View solution in original post

Highlighted
Resolver II
Resolver II

Re: Formula to remove letters

@gabibalaban @Eelman 

Thanks for the replies!

I modified one of the formulas to do the spaces correctly since it's not always - e.g. one1 three3 two2 five5 = 1 3 2 5

and the spaces are sporadic.

Thanks ^^

Highlighted
Super User
Super User

Re: Formula to remove letters

@kamikaze4416 

Which solution helped you?  I would suggest giving kudos the person who provided you with the inspiration as a way of saying "thank you".  Kudos are a great way to let someone know you appreciated the time they put into helping you out.

 

It would be a good idea to share the solution you came up with for the benefit of future readers. I want to learn what you learned.  If the person came up with 98% of the solution and you changed it by 2% to get your specific use case consider marking their answer as the solution.  You could also mark you own answer as the solution.  In any case, if the issue is solved is it a good practice to mark the solution.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Resolver II
Resolver II

Re: Formula to remove letters

Hi @mdevaney ,

The solution I ended with was - Trim(Concat(Split(InitialValue,""),If(IsBlankOrError(Value(Result)) && !(Result = " "),"",Result),""))

I chose this out of the two solutions simply out of personal preference to fit toward my own coding style.

Both answers by @gabibalaban and @Eelman were equally helpful without my personal bias so I wouldn't know which to mark as a solution.

Kudos given and I'll mark this as the solution 👌

View solution in original post

Highlighted
Super User
Super User

Re: Formula to remove letters

@kamikaze4416 

Thank you very much for doing.  I thought both answers were interesting and just wanted to see them get credit.  No harm done.  Just trying to help out here 🙂

 

Fun fact: you can Accept more than one post as the Solution.  This is a little known fact.  Now you are part of the 10% of people who know this LOL 🤣

Highlighted
Resolver II
Resolver II

Re: Formula to remove letters

@mdevaney 

ah **bleep**

guess we're gonna have 3 solutions now xD

Highlighted
Resolver II
Resolver II

Re: Formula to remove letters

I didn't even swear, it seems worse cause it bleeped o.o

Highlighted
Super User
Super User

Re: Formula to remove letters

@kamikaze4416 

Hahaha.  I'm sure no one will complain about that 😆

 

Another fun fact: the PowerApps forum blocks swear words and changes them to the text *bleep*.  I can only imagine what you actually said LOL.  😏

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (6,231)