title: RegexValidator for Zipcodes
body: <p>I have been working with Django and RegexValidator on a field where I would only like to save a valid US Zipcode in the format of DDDDD or DDDDD-DDDD. </p>
  
  <p>I have set up my variable in the model as the following: </p>
  
  <pre><code>zip = models.CharField(
      max_length=10,
      null=True,
      blank=True,
      help_text=_("Zipcode"),
      validators=[RegexValidator(
          regex=r'^(^[0-9]{5}(?:-[0-9]{4})?$)?$)',
          message=_(u'Must be valid zipcode in formats 12345 or 12345-1234'),
      )],
  )
  </code></pre>
  
  <p>At this point, I am trying to create a regex that will also save empty strings as well. I have tried to look at the following questions <a href="https://stackoverflow.com/questions/11127515/regex-for-5-digit-zip-or-empty">RegEx for 5 digit zip or empty</a>
  <a href="https://stackoverflow.com/questions/5063977/regex-empty-string-or-email">Regex empty string or email</a>
  and tried adding a "|" before, as well as an "?" at the end. </p>
  
  <p>Any other suggestions or advice?</p>