Rick J. Posted December 8, 2022 Share Posted December 8, 2022 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. Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted December 8, 2022 Share Posted December 8, 2022 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. Quote Link to comment Share on other sites More sharing options...
Rick J. Posted December 8, 2022 Author Share Posted December 8, 2022 Thank you Thomas. Worked like a champ. I knew there was something simple to fix the issue. Thanks so much. Quote Link to comment Share on other sites More sharing options...
hopkinsprinting Posted July 18 Share Posted July 18 Hi Tom, Although your code snippet worked like a charm for me, I was wondering if there is a way to return specific characters in a field? Let's say, the first 5 characters. Can this also be done in FusionPro? Thank you, hp Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted July 18 Share Posted July 18 3 hours ago, hopkinsprinting said: Although your code snippet worked like a charm for me, I was wondering if there is a way to return specific characters in a field? Let's say, the first 5 characters. Can this also be done in FusionPro? return Left(Field("YourFieldName"), 5); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.