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
Solved! Go to Solution.
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")
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!
@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")
Thank you so much!