title: Regex for quoting unquoted XML attributes
body: <p>Edit: The 100% correct theory is that you don't want to do this at all. However I have accepted the answer that helped the most.</p>
  
  <p>So I'm being given ugly XML from a client that promises to fix it. In the meantime I need to clean it up myself. I'm looking for a regex to use in Java to add quotes around unquoted attributes. The general case is better, but so far it is only one attribute that is broken so the regex can specifically refer to "attr1". The value of the attribute is unknown, so I can't include that in the search.</p>
  
  <pre><code>&lt;tag attr1 = VARIABLETEXT&gt;
  &lt;tag attr1 = "VARIABLETEXT"&gt;not quoted&lt;/tag&gt;
  &lt;tag attr1 = VARIABLETEXT attr2 = "true"&gt;
  &lt;otherTag&gt;buncha junk&lt;/otherTag&gt;
  &lt;tag attr1 = "VARIABLETEXT"&gt;"quoted"&lt;/tag&gt;
  </code></pre>
  
  <p>Should turn into</p>
  
  <pre><code>&lt;tag attr1 = "VARIABLETEXT"&gt;
  &lt;tag attr1 = "VARIABLETEXT"&gt;not quoted&lt;/tag&gt;
  &lt;tag attr1 = "VARIABLETEXT" attr2 = "true"&gt;
  &lt;otherTag&gt;buncha junk&lt;/otherTag&gt;
  &lt;tag attr1 = "VARIABLETEXT"&gt;"quoted"&lt;/tag&gt;
  </code></pre>
  
  <p>EDIT: Thank you very much for telling me not to do what I'm trying to do. However, this isn't some random, anything goes XML, where I'll run into all the "don't do it" issues. I have read the other threads. I'm looking for specific help for a specific hack.</p>