It's beginning to look a lot like...Advent of Code! Get in the holiday spirit by learning how you can participate in this friendly competition and earn a seasonal badge.

Alteryx Designer Desktop Discussions

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

Parsing a specific number of characters within a string

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.



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.




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


15 - Aurora
15 - Aurora

Hi @Desa19,


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






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.




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.




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