title: TextWrangler FInd/Replace with
body: <p>I have long lists of location data, which is in XML format.</p>
  
  <pre><code>&lt;location&gt;&lt;city&gt;London&lt;/city&gt;&lt;name&gt;Zoo&lt;/name&gt;&lt;latitude&gt;...&lt;/location&gt;
  </code></pre>
  
  <p>Unfortunately the XML is corrupt and I have to replace/fix a lot of
  invalid close XML tag occurances. Example, here <code>&lt;/name&gt;</code> has to be replaced with <code>&lt;/city&gt;</code>:</p>
  
  <pre><code>&lt;location&gt;&lt;city&gt;London&lt;/name&gt;&lt;latitude&gt;...&lt;/location&gt;
  </code></pre>
  
  <p>Using TextWrangler Find+Replace I can search for:<code>&lt;city&gt;[A-Za-z]*&lt;/name&gt;</code>
  That statement searches and finds all the invalid lines. So far so good.</p>
  
  <p>Now I want to replace them automatically (Replace All). Normally in regular expressions this is done by defining: <code>&lt;city&gt;%1&lt;/city&gt;</code> but that is not working. It overwrites the found text, not interpreting the search result nor inserting the value in the <code>%1</code> tag.</p>