title: Removing parenthesis from phone numbers and adding dash using preg_replace
body: <p>I'm brand new to PHP, so, forgive me if this is an easy question, but I can't really figure out how to use <code>preg_replace</code> to strip the parenthesis from the area codes in my phone numbers and add a dash between the area code and the first 3 digits. </p>
  
  <p>Right now all of my phone numbers are stored separately in each person array (which are in the index file) in this format: <code>(800) 111-1111</code>. </p>
  
  <p>I want to get them to print out like this: <code>800-111-1111</code> and I want to make this all happen in the <code>setphoneNumber</code> function of my <code>Person</code> class. </p>
  
  <p>Here is what the code looks like:</p>
  
  <pre><code>$this-&gt; phoneNumber = $phoneNumber;  
  $pattern = ('/\D+/');
  $replacement = '';
  if(is_string($phoneNumber)) {
      return preg_replace($pattern, $replacement, $this -&gt; phoneNumber);
  } else {
      user_error("Error: Person's phone number must be a string");
  } 
  </code></pre>
  
  <p>Any modifications that I do to it either gives me an unmatched parenthesis at offset error or a no ending delimiter error (which occurs when I set <code>$pattern</code> as <code>(')'</code>);</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks all!</p>