Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Find 4 Digit Number from Inside String

AlteryxUserFL
11 - Bolide

I need to find a 4 digit number located in a string. The main characteristics are that the number will always be at the front of the string or be located between underscores. Is there a way to find this using only the formula tool? 

 

AMG_GMBHG_1025_20191018_46305.pdf

AMG_WWHOL_1086_20191021_00168.pdf

AMG_SASFR_1031_20191021_16928.pdf

UU_1001_10222019_01433.pdf

1071_20191019_00465449.pdf

3 REPLIES 3
fmvizcaino
17 - Castor
17 - Castor

Hi @AlteryxUserFL ,

 

I was not able to think of an easy way of getting the 4 digit number using only a formula tool. But it is pretty easy to get it using the regex tool.

 

fmvizcaino_0-1576258652671.png

 

Let me know if that works for you.

Best,

Fernando Vizcaino

ponraj
13 - Pulsar

Here is the sample workflow. 

solution.PNG

MarqueeCrew
20 - Arcturus
20 - Arcturus

I'm on my iPhone now, but you might try this formula:

 

Regex_Replace([field],".*?\D*?(\d{4})\D*.*",'$1')

 

 cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels
Top Solution Authors