title: Regular expression for apostrophes/ single quotes with double
body: <p>I'm currently working with a regular expression (in Javascript) for replacing double quotes with smart quotes:</p>
  
  <pre><code>// ie: "quotation" to &amp;ldquo;quotation&amp;rdquo;
  </code></pre>
  
  <p>Here's the expression I've used for replacing the double quotes:</p>
  
  <pre><code>str = str.replace(/"([A-Za-z ]*)"/ig, "&amp;ldquo;$1&amp;rdquo;")
  </code></pre>
  
  <p>The above works perfectly if the phrase inside the quotes contains no additional punctuation, however, I also need to replace any apostrophes:</p>
  
  <pre><code>// ie: replace "It's raining again" with &amp;ldquo;It&amp;rsquo;s raining again!&amp;rdquo;
  </code></pre>
  
  <p>The expression for replacing single quotes/ apostrophes works fine if not encapsulated:</p>
  
  <pre><code>str.replace(/\'\b/g, "&amp;rsquo;"); // returns it's as it&amp;rsquo;s correctly
  
  // Using both:
  str.replace(/"([A-Za-z ]*)"/ig, "&amp;ldquo;$1&amp;rdquo;").replace(/\'\b/g, "&amp;rsquo;");
  
  // "It's raining again!" returns as "It&amp;rsquo;s raining again!"
  // Ignores double quotes
  </code></pre>
  
  <p>I know this is because the expression for replacing the double quotes is being matched to letters only, but my limited experience with regular expressions has me flummoxed at how to create a match for quotations that may also contain single quotes!</p>
  
  <p>Any help would be HUGELY appreciated! Thanks in advance.</p>