Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to keep just the numbers in a certain string?

Su
7 - Meteor

Hi there,

 

 

 

How can I just keep the numbers ina  certain string, for example:

 

address = "Maistraße 37" or address = "64 Redemarsh" 

 

On the first example I want to get 37 and the on the second 64, is this possible using the trim function? if yes, how? or is there any other way?

 

Thanks in advance.

Susana

8 REPLIES 8
AdamR_AYX
Alteryx Alumni (Retired)

Try this

 

REGEX_Replace([Address], "[\D]", "")

 

It uses regex to replace anything that is not a digit with a blank string.

Adam Riley
https://www.linkedin.com/in/adriley/
Su
7 - Meteor

Thanks a lot! It works perfectly :)

Casparov
5 - Atom

Hello,

 

How would this work if you also want to keep decimals . For example, "Bonus 3,5%" => 3.5. Using this formula above I will get 35.

 

Many thanks,

Casper

AdamR_AYX
Alteryx Alumni (Retired)

RegEx tool in parse mode with

 

(\d.%)

 

Hmmm... Did you change your question?

Adam Riley
https://www.linkedin.com/in/adriley/
Casparov
5 - Atom

Hi Adam,

 

I did, but if that also results in the percentage value including decimals that is fine. 

 

Thanks a lot!

Casparov
5 - Atom

Hi Adam,

 

Maybe it has to do with the fact that the field is 'Wstring'. I cannot just simply convert it to V_String; this renders a lot of errors.

 

This formula helped me in getting only the digits: 

REGEX_Replace([Description], "[\D]", "")

 

However, this changes 9,1% into 91.

 

Is there a way to take this into account?

 

If it is easier to use parse (\d.%), please let me know how I can set this up properly, as it returns only null values at the moment.

 

Many thanks again,

Casper

balubindass
5 - Atom

Please use the Regex Tool instead of writing regex in the formula tool.

[/d.%]|[/d.d%] or condition will help pick multiple scenarios as well.

 

Hope this is helpful

minhdvo
7 - Meteor

Thanks. It works for me.

Labels