Skip to main content

Regular Expressions | How to Add Hyphens to Zip Codes Without Hyphens

Yoom Customer Service avatar
Written by Yoom Customer Service
Updated this week

📝 Overview

If you have postal codes (zip codes) without hyphens and need to add them, you can do so using “Data Conversion” in Yoom, specifically by selecting the “Replace Data" (Regular Expression) action.

👉 For more details on how to write regular expressions, please refer to this article: How to Write Regular Expressions.


🛠️ How to Configure

  1. Select Data Conversion and choose Replace Data as the conversion type.

  2. For postal codes with 5 digits (e.g., 12345), set the Search target (Regular Expression) as:

    (?<=^.{4})(?=.)(?!.*-)

    This adds a hyphen after the fourth character (e.g., 1234-5).

    If the postal code has 4 digits, set the Search target (Regular Expression) to:

    (?<=^.{3})(?=.)(?!.*-)

    This adds the hyphen after the third character (e.g., 123-4).

    This setup works for U.S. zip codes or similar formats.

    For international addresses with different formatting rules, you might need to adjust the regular expression or review the structure of the postal codes.


📚 Related Guides

Related Keywords

regular expressions, zip code, postal code, hyphen, data transformation, data replacement, Yoom, formatting, U.S. zip code, international addresses, string manipulation, regular expression guide

Did this answer your question?