Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Alteryx is here to help you solve your biggest data challenges. Read about the new Virtual Solution Center here.
SOLVED

How to keep just the numbers in a certain string?

Highlighted
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

Highlighted
Alteryx
Alteryx

Try this

 

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

 

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

Adam Riley
Principal Software Engineer
Tech Lead Core Engines, Alteryx
Highlighted
7 - Meteor

Thanks a lot! It works perfectly :)

Highlighted
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

Highlighted
Alteryx
Alteryx

RegEx tool in parse mode with

 

(\d.%)

 

Hmmm... Did you change your question?

Adam Riley
Principal Software Engineer
Tech Lead Core Engines, Alteryx
Highlighted
5 - Atom

Hi Adam,

 

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

 

Thanks a lot!

Highlighted
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

Highlighted
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

Labels