title: How do I match a pattern with optional surrounding quotes?
body: <p>How would one write a regex that matches a pattern that can contain quotes, but if it does, must have matching quotes at the beginning and end?</p>
  
  <pre><code>"?(pattern)"?
  </code></pre>
  
  <p>Will not work because it will allow patterns that begin with a quote but don't end with one.</p>
  
  <pre><code>"(pattern)"|(pattern)
  </code></pre>
  
  <p>Will work, but is repetitive.  Is there a better way to do that without repeating the pattern?</p>