title: Replace sequence of words in string with string python
body: <p>I couldn't find anything that could solve this (<code>replace()</code> method doesn't work).</p>
  
  <p>I have a sentence like:</p>
  
  <pre><code>sentence_noSlots = "Albania compared to other CountriesThe Internet users of Albania is similar to that of Poland , Portugal , Russia , Macedonia , Saudi Arabia , Argentina , Greece , Dominica , Azerbaijan , Italy with a respective Internet users of 62.8 , 62.1 , 61.4 , 61.2 , 60.5 , 59.9 , 59.9 , 59.0 , 58.7 , 58.5 -LRB- per 100 people -RRB- and a global rank of 62 , 63 , 64 , 65 , 66 , 68 , 69 , 70 , 71 , 72.10 years growthAlbania 's Internet users had a positive growth of 5,910 -LRB- % -RRB- in the last 10 years from -LRB- 2003 to 2013 -RRB- ."
  </code></pre>
  
  <p>I then have a string like: </p>
  
  <pre><code>extracted_country = Saudi Arabia 
  extracted_value = 58.5
  </code></pre>
  
  <p>I need to replace <code>Saudi Arabia</code> in the string with <code>&lt;location&gt;empty&lt;/location&gt;</code> and <code>58.5</code> with <code>&lt;number&gt;empty&lt;/number&gt;</code>. My current method is:</p>
  
  <pre><code>sentence_noSlots.replace(str(extracted_country),"&lt;location&gt;empty&lt;/location&gt;")
  sentence_noSlots.replace(str(extracted_value),"&lt;number&gt;empty&lt;/number&gt;")
  </code></pre>
  
  <p>However because Saudi Arabia is two words, a simple word replace doesn't work. Nor does tokenizing first and replacing work due to the same type of issue:</p>
  
  <pre><code> sentenceTokens = sentence_noSlots.split()
                              for i,token in enumerate(sentenceTokens):
                                  if token==extracted_country:
                                      sentenceTokens[i]="&lt;location&gt;empty&lt;/location&gt;"
                                  if token==extracted_value:
                                      sentenceTokens[i]="&lt;number&gt;empty&lt;/number&gt;"
                              sentence_noSlots = (" ").join(sentenceTokens)
  </code></pre>
  
  <p>How can I achieve what I want to achieve?</p>