Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Parsing String from Specific Comma

jakemancer
7 - Meteor

Hi,

 

I have a field within which all records concatenated example locations in a string, each location is separated by a comma. Is there a way I can parse these fields to keep just the first two example locations i.e. remove anything after the 3rd separating comma?

 

Thanks

4 REPLIES 4
Kenda
16 - Nebula
16 - Nebula

Hey @jakemancer! Try putting this in a Formula tool. It worked for me in a sample set of data I made up.

 

REGEX_Replace([location], "(.*?)\,(.*?)(\,.*)", "$1\,$2")
jakemancer
7 - Meteor

Thanks @BarnesK!

 

That works for what I want to do. How would I change it to remove strings say after the 3rd, 4th comma etc. if I want some additional locations present?

 

Many thanks!

Kenda
16 - Nebula
16 - Nebula

@jakemancer You could just keep following the pattern. Basically add another ,(.*?) before the (,.*) in the middle section and then add another $# in the last section. (Note I changed the formula a little because I realized you don't really need the \ symbol.)


Remove after 3rd: 

REGEX_Replace([location], "(.*?),(.*?),(.*?)(,.*)", "$1,$2,$3")

Removing after 4th:

REGEX_Replace([location], "(.*?),(.*?),(.*?),(.*?)(,.*)", "$1,$2,$3,$4")
jakemancer
7 - Meteor

Thank you so much!

Labels