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.
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
Thank you much @DataNath ! It worked.