Advent of Code is now back for a limited time only! Complete as many challenges as you can to earn those badges you may have missed in December. Learn more about how to participate here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Extract filename data

charlescooks
5 - Atom

Dear all, 

I'm trying to extract the first 10 digits and last 4 digits of the following filename: "0423855851 DRAFT PS 2021.xlsx"

Any chance you can help me write the correct regex to use with the regex tool in alteryx ? 

 

4 REPLIES 4
binuacs
21 - Polaris

@charlescooks One way of doing this. I am not sure you want all the numbers in one column or separate columns like below.

 

binuacs_0-1663156870401.png

 

grazitti_sapna
17 - Castor

Hello @charlescooks . You can also use the below regex expressions for extracting first 10 and last 4 digits.

 

Thanks!!

 

grazitti_sapna_0-1663213742102.png

 

 

Sapna Gupta
flying008
15 - Aurora

Hi,@charlescooks 

 

If you only want get the numeric of filename, follow this formula:

 1- Get all number:

 

REGEX_Replace([FileName], "^(\d{10}).*(\d{4}).+?$", "$1$2")

 

 

2- Get First 10 number :

 

REGEX_Replace([FileName], "^(\d{10}).*(\d{4}).+?$", "$1")

 

 

3- Get last 3 number:

 

REGEX_Replace([FileName], "^(\d{10}).*(\d{4}).+?$", "$2")

 

 

flying008_0-1663216280903.png

*******

Please mark this as the solution if it answers your question, it will help others to find solutions quicker.

Emmanuel_G
13 - Pulsar

Hi @charlescooks ,

 

Find attached the way to do that with Regex Tool.

 

Emmanuel_G_0-1663345609840.png

 

Labels
Top Solution Authors