title: Seeking regex for HTML attributes meeting specific criteria
body: <p>I'm trying to remove single quotes and double quotes around HTML attributes with the following restrictions:</p>
  
  <p>1) The quoted material MUST exist <em>within</em> a tag <code>&lt;&gt;</code> (e.g., <code>&lt;mytag b="yes"&gt;</code> becomes <code>&lt;mytag b=yes&gt;</code>, but <code>&lt;script&gt;var b="yes"&lt;/script&gt;</code> stays intact).</p>
  
  <p>2) The quoted material may not have a space character nor an equal sign (e.g., <code>&lt;mytag b="no no" c="no=no"&gt;</code> stays intact).</p>
  
  <p>3) The quoted material may not be in an <code>href</code> or <code>src</code> definition.</p>
  
  <p>4) The regex should be good for UTF-8 (duh!)</p>
  
  <p>Someone posted a virtually identical question here that received an answer that works within the confines of the question:</p>
  
  <p><a href="https://stackoverflow.com/questions/23587701/removing-single-and-double-quote-from-html-attributes-with-no-white-spaces-on-al">Removing single and double quote from html attributes with no white spaces on all attributes except href and src</a></p>
  
  <p>So:</p>
  
  <p><code>((\S)+\s*(?&lt;!href)(?&lt;!src)(=)\s*)(\"|\')(\S+)(\"|\')</code></p>
  
  <p>...works, except it fails to isolate text within tags (i.e., text in between opening and closing tags is erroneously edited, e.g. <code>&lt;mytag&gt;"The quotes are stripped out here!"&lt;/mytag&gt;</code>), and it doesn't check for equal signs (=) within the quoted text (e.g. <code>&lt;mytag b="OhNo=TheRoutineRemovedTheQuotesBecauseItDidNotCheckForAnEqualSignInTheQuotedText!"&gt;</code>).</p>
  
  <p>Bonus points: I wish to integrate this into this php HTML minification routine, which works well except for the edits described above:</p>
  
  <p><a href="https://gist.github.com/tovic/d7b310dea3b33e4732c0" rel="nofollow">https://gist.github.com/tovic/d7b310dea3b33e4732c0</a></p>
  
  <p>His solution pairs the patterns and replacement params in two arrays, as you'll see, so I need to conform to his syntax, which uses <code>#</code>, etc.</p>
  
  <p>Your solution get my upvote!</p>