title: What regular expression will match a pattern or be empty?
body: <p>I need regular expression that matches a pattern or is empty.</p>
  
  <p>Right now I have an expression...</p>
  
  <pre><code>"\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x"
  </code></pre>
  
  <p>... which matches US phone numbers. However, it is valid for the string I'm testing to be empty. If the string has any value in it at all, it must match the expression.</p>
  
  <p>I have other patterns which match US postal codes, etc that need the same conditional.</p>
  
  <p>What is the best way to achieve this in the same expression?</p>
  
  <p><strong>Clarification</strong>: I am using the RegexValidator in the Validation Application Block from Microsoft. An example of using this is as follows:</p>
  
  <pre><code>[StringLengthValidator(0, 100, MessageTemplate = "Email must be between {3} and {5}")]
  [RegexValidator(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", MessageTemplate = "Valid Email Required.")]
  public string EmailAddress
  {
      get { return _EmailAddress; } 
      set { SetValue&lt;string&gt;(ref _EmailAddress, value); }
  }
  </code></pre>
  
  <p>This is why I need the solution to be in one expression.</p>