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

I Need REGEX Replace, I just dont know how

AL3XE167
6 - Meteoroid

Hi,

 

I have concatenated a number of fields and set them out in a very particular format, to be later included in an automated email via Alteryx. My data before concatenation looked like this;

 

Record IDField 1Field 2Field 3Field 4Field 5
1Monthly SpendMonthly Finance PositionDirectorate Finance PositionCapital PositionResource Position
2BAMEFixed Term ContractsHeadcount  

 

I have then added a formula to Add each field together

 

"- "+ [Field 1] +",

- " + [Field 2 +",

-" etc.

 

This gives me what I want for Record ID 1 but gives me the following for Record ID 2;

- BAME,

- Fixed Term Contracts,

- Headcount,

-,

-,

 

How do I get rid of the unnecessary characters at the end "-,-," ? I assume REGEX will do it but I am unsure of how to do this.

 

Thanks in advance

 

3 REPLIES 3
Greg_Murray
12 - Quasar

hi @AL3XE167,

 

I might take a slightly different approach, see attached.

Greg_Murray_0-1584458663744.png

 

AL3XE167
6 - Meteoroid

Thanks Greg, I was so intent on using REGEX I couldnt even think of any other option. 

 

Thanks

Alex

Thableaus
17 - Castor
17 - Castor

Hi @AL3XE167 

 

@Greg_Murray's solution is definitely elegant and much more helpful, but here's a REGEX that would work:

 

Using Formula Tool

REGEX_Replace(Field], "(.*\w),.*", "$1")

 

This would capture everything until your last "word" character.

 

Cheers,

Labels