Parsing String from Specific Comma
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you so much!
