Alteryx Designer Desktop Discussions

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

Parsing a specific number of characters within a string

Desa19
7 - Meteor

Dear community,

 

Please I am having some difficulties using Regex to extract a specific part of a string field within my Data.

I have for example a field with the following string: 99999998_20180501_001_21_11+22_ORDERS

 

I will like to extract the Year and Month (marked in green) for each single record within that field. The field ist automatically generated and the date changes depending on the date of input of the record (YYYYMMDD), else the format remains the same for all the records. Only exception could be the prefix that could vary between "ORDERS" and "OFFERS"

 

I will appreciate your assistance.

 

Thanks

4 REPLIES 4
afv2688
16 - Nebula
16 - Nebula

Hello @Desa19,

 

I've put you two ways to get to the same info with some extra columns to classify by date.

 

Untitled.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Regards

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Desa19,

 

You could use the following expression to parse the YearMonth into a new column:

 

\d+_(\d{6}).*

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

CharlieS
17 - Castor
17 - Castor

This can be done in a single Formula tool. This will work for the 8-digit date string in any position in the input string, as long as it is bound between two underscores.

 

Left(REGEX_Replace([Input],".*\_(\d{8})\_.*","$1"),6)

 

Desa19
7 - Meteor

@CharlieS @Jonathan-Sherman @afv2688,

 

please accept my appreciations for the timely assistance, I just successfully pulled the right results with all three options. 

 

@CharlieS @Jonathan-Sherman: your proposed solutions, though slightly different approaches nail the problem on the point with the exact solution.

@afv2688's Option broadens my scope further on how to correctly format the Regex Tool for other possible outputs.

 

Thanks for all 

Labels