Jump to content

Trim a field after a specific character

Rick J.

Recommended Posts

I've received a file that has the address, city, state and zip all in one field. It has a comma after the street address and the city. Is there a way to trim the field to remove the everything from the comma after the street address, so it only returns the street address. The filed varies in length of course so I can't use a static number to trim.
Link to comment
Share on other sites

There's a few different ways to do this with substrings and regular expressions but I think the easiest is to use split.


return Field("Address").split(",")[0];


This splits the string into segments at every comma. [0] is the first part, [1] would be the next, in this case city, then [2] would be state, etc. The only issue would be if the address contained a comma, for instance with an apartment number. That would end up in the next segment.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...