title: Check if the format of string matches desired format using Regex
body: <p>I'm trying to write code that will take a given string and compare it to a certain format.
  This is what I'm using:</p>
  
  <pre><code>private static readonly Regex phoneNumber = new Regex(@"\d{3}-\d{3}-\d{4}");
  
  public static bool VerifyPhoneNumber(string pNumber)
  {
      return phoneNumber.IsMatch(pNumber);
  }
  </code></pre>
  
  <p>The format is <code>000-000-0000</code>, and it returns true when comparing it to <code>555-555-5555</code>. I also have a <code>MessageBox</code> displaying <code>pNumber</code> and <code>phoneNumber</code> for comparison purpose. The Message Box displays: <code>pNumber = 555-555-5555</code> and <code>phoneNumber = \d{3}-\d{3}\d{4}</code></p>
  
  <p>But that isn't the format I want. I want to use this format (000)000-0000. In order to use this format I changed phoneNumber to this:</p>
  
  <pre><code>private static readonly Regex phoneNumber = new Regex("(" + @"\d{3}" +  ")" + @"\d{3}-\d{4}");
  </code></pre>
  
  <p>But when I run this code and compare <code>(555)555-5555</code> to it, it returns false. The <code>MessageBox</code> for this displays: <code>pNumber = (555)555-5555</code> and <code>phoneNumber = (\d{3})\d{3}-\d{4}</code></p>
  
  <p>Now I don't know enough about <code>Regex</code> yet to fix this issue myself. Based on my research so far, the () are causing the issue. I believe its because () are used for regular expressions and dashes aren't. So, the dash doesn't mess anything up. My question is how can I change my code to fit my needs? How can I get the () in the code without issues?</p>