Start a new topic

Zip Code Formatting

What is the coding for setting up a Regular Expression for a 9-digit zip code with a leading zero so that the dash appears in the address output? We are able to add the leading zero, but have been unable to include the dash (the dash is not in the original data).


It is probably easiest to do this with two regular expressions in one dictionary. Since replacement values are processed in the order they are entered you would want these to be in the below order.

Replacement Value: 0$&
Value to match on: ^\d{8}$

Replacement Value: $1-$2
Value to match on: (^\d{5})(\d{4}$)

The first one will add a leading zero if your field contains only 8 digits. The second will split the 9 digits into two groups of 5 digits and 4 digits and then place a "-" between them.

Thank you Nic! It worked perfectly.
Login or Signup to post a comment