SOLVED
How to add a dash to SOME zip codes only
Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
vmirand
6 - Meteoroid
‎02-20-2024
08:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello. I am trying to add a dash to the zip codes with a length of more than 5 NUMERIC characters only. Also, I have zip codes of 6 characters (letters and numbers) that I am not looking to edit. Can somebody please help me with a formula that meets those conditions?
Zip code | Result |
986044850 | 98604-4850 |
79936 | 79936 |
564654262 | 56465-4262 |
R2X1G7 | R2X1G7 |
Thank you
Solved! Go to Solution.
Labels:
- Labels:
- Tips and Tricks
- Workflow
2 REPLIES 2
17 - Castor
‎02-20-2024
09:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey @vmirand, there's a few ways to go about this - here's what I've quickly put together:
Formula expression:
IF REGEX_Match([Zip code], '\d{6,}')
THEN REGEX_Replace([Zip code], '(.{5})(.*)', '$1'+'-'+'$2')
ELSE [Zip code]
ENDIF
Without RegEx you could use standard functions to do something like:
IF Length([Zip code]) > 5 AND IsInteger([Zip code])
THEN Left([Zip code], 5) + '-' + Right([Zip code], Length([Zip code])-5)
ELSE [Zip code]
ENDIF
‎02-20-2024
09:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you much @DataNath ! It worked.
