Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
ALTER.NEXT:

Join us on Dec 2 for a half-day virtual analytics + data science event!
US & CA customers only

SAVE YOUR SPOT
It's the most wonderful time of the year - Santalytics 2020 is here! This year, Santa's workshop needs the help of the Alteryx Community to help get back on track, so head over to the Group Hub for all the info to get started!
SOLVED

RegEx Replace

5 - Atom

Hello!

 

I have some data that I need to add commas between, see below example.

 

abcdef I need formatted as a,b,c,d,e,f.

 

I currently have REGEX_Replace([Text], "", ',') where it gives me ,a,b,c,d,e,f,. I then have a separate formula to remove the front comma, REGEX_Replace([Output], "^(\W)", '') and third to remove the end comma, REGEX_Replace([Output], "(\W)$", ''). I can "nest" these together (REGEX_Replace(REGEX_Replace(REGEX_Replace([Text], "", ','), "^(\W)", ''), "(\W)$", '')) and it gives me what I need, but strictly for learning purposes, I am wondering if there is a more efficient way to do this.

 

Thanks in advance!

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

Hi @DrewL 

 

One alternative to consider is using a RegEx tool to split the characters into rows, then a Summarize tool to concatenate them back together with commas between.

 

Check out the attached workflow for an example. 

Highlighted
17 - Castor
17 - Castor

Hi @DrewL 

 

A slightly simpler option would be this

 

Trim(REGEX_Replace([Field1], "(.)", "$1,"),",")

 

Dan

 

Highlighted
5 - Atom

Thank you!

Labels