title: Replacing HTML tag content using sed
body: <p>I'm trying to replace the content of some HTML tags in an HTML page using sed in a bash script. For some reason I'm not getting the proper result as it's not replacing anything. It has to be something very simple/stupid im overlooking, anyone care to help me out?</p>
  
  <p>HTML to search/replace in:  </p>
  
  <pre><code>Unlocked &lt;span id="unlockedCount"&gt;&lt;/span&gt;/&lt;span id="totalCount"&gt;&lt;/span&gt; achievements for &lt;span id="totalPoints"&gt;&lt;/span&gt; points.
  </code></pre>
  
  <p>sed command used:  </p>
  
  <pre><code>cat index.html | sed -i -e "s/\&lt;span id\=\"unlockedCount\"\&gt;([0-9]\{0,\})\&lt;\/span\&gt;/${unlockedCount}/g" index.html 
  </code></pre>
  
  <p>The point of this is to parse the HTML page and update the figures according to some external data. For a first run, the contents of the  tags will be empty, after that they will be filled.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I ended up using a combination of the answers which resulted in the following code:</p>
  
  <pre><code>sed -i -e 's|&lt;span id="unlockedCount"&gt;\([0-9]\{0,\}\)&lt;/span&gt;|&lt;span id="unlockedCount"&gt;'"${unlockedCount}"'&lt;/span&gt;|g' index.html
  </code></pre>
  
  <p>Many thanks to @Sorpigal, @tripleee, @classic for the help!</p>