Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

extract nth split regex

jcardoso
8 - Asteroid

nth_split.png

 

Hi, i want to extract the nth split by delimiter '_', i was trying with an IF statement on the B column IF [bp]=A THEN .....

but i'm struggling with the regex functions.

Any help appreciated, Thanks 

6 REPLIES 6
NickSm
Alteryx
Alteryx

@jcardoso  - Probably a few ways to approach this, depending if it's the same nth split that you want to parse out every time or if it's more of a pattern that you're looking for.

 

The sample provided doesn't have the "bp" column, so any additional info you can provide can help us give a better response.

jcardoso
8 - Asteroid

Thank you, it's a parse, but the index where should be taken from it's in different positions, dependending on the bp.


File updated attached, my apologies,

 

Thank you so much

afv2688
16 - Nebula
16 - Nebula

Hello @jcardoso ,

 

I think this does the trick:

 

Untitled2.png

 

These are the formulas:

 

IF REGEX_Match([FileName], '(.*\_)(\d{7,8})(\_.*|\.xlsx)') THEN REGEX_Replace([FileName], '(.*\_)(\d{7,8})(\_.*|\.xlsx)', '$2') ELSE Null() ENDIF

 

IF IsNull([awdad]) and REGEX_Match([FileName], '(.*\_)(\d{4}\-\d{2}\-\d{2})(\s.*)') THEN REGEX_Replace([FileName], '(.*\_)(\d{4}\-\d{2}\-\d{2})(\s.*)', '$2') ELSE [awdad] ENDIF

 

IF IsNull([awdad]) and REGEX_Match([FileName], '(.*\_)(\d{4}\-\d{2}\-\d{2})(\_.*)') THEN REGEX_Replace([FileName], '(.*\_)(\d{4}\-\d{2}\-\d{2})(\_.*)', '$2') ELSE [awdad] ENDIF

 

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

 

Regards

PhilipMannering
16 - Nebula
16 - Nebula

Could you use the Regex tool set to parse and use,

 

_(\d{4}-?\d{2}-?\d{2})

 

 

P

BetterFerret
8 - Asteroid

@jcardoso,

You might find my set of custom formulas useful.  It includes a Split() function and a StandardDate() function that might be useful as well.

https://community.alteryx.com/t5/Alteryx-Designer-Ideas/Custom-Functions/idi-p/467216

jcardoso
8 - Asteroid

Thank you

 

although this would need to be adapted to each of the different date formats, yes, it solves the case.

Labels