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

Extracting specific data from a field

mihaicom20
8 - Asteroid

Hello Everyone,

 

I am struggling  with a problem that I couldn't find any solution on other topics that can fit my request.

I have a database from which I need to extract the first 4 to 9 digits on a separate col. in order to use it for a Join, but there is no specific conditions that are applied. On the photo attached you can see the input and the output that I want to have. I tried to eliminate the letters with the Data Cleansing tool, but after I need to find out how to extract the first 4 to 9 digits after first: space or / or . or , or any other characters.

 

Thank you in advance!  

4 REPLIES 4
mot
11 - Bolide

Hi @mihaicom20 ,

 

Please see attached. I hope this helps. Best.

AndrewS
11 - Bolide

Hi @mihaicom20 , a little regex should get you there..

 

Spoiler
regex.PNG
mihaicom20
8 - Asteroid

@mot @AndrewS  First of all thank you so much for help!

 

There is any chance to explain what is exactly doing: (^\d*) or ^(\d+)(?:.*)  in order to know how to apply/build it in future Alteryx flows with different requests? 

AndrewS
11 - Bolide

Hi @mihaicom20 , no problem at all. I went over to regex101.com and entered both the solutions offered. The captures below show you what each section of the regex is doing and explains it step-by-step on the right hand side. As you can see, they both provide the same end result. If you look at the regex tool in Alteryx, you will see the common regex available as a guide in the dropdown, this can also guide you when building it out - I've highlighted where these are and screen captured below. They are both basically just searching for any number of digits.

 

Check out regex101.com if you can, it allows you to enter your text and then play around and test your regex syntax. I also found it a good site when starting to learn regex.

 

Cheers,

Andrew.

Spoiler
regex2.PNGregex3.PNG
Spoiler
regex4.PNG
Labels