title: Python finding substring between certain characters using regex and replace()
body: <p>Suppose I have a string with lots of random stuff in it like the following:</p>
  
  <pre><code>strJunk ="asdf2adsf29Value=five&amp;lakl23ljk43asdldl"
  </code></pre>
  
  <p>And I'm interested in obtaining the substring sitting between 'Value=' and '&amp;', which in this example would be 'five'.</p>
  
  <p>I can use a regex like the following:</p>
  
  <pre><code> match = re.search(r'Value=?([^&amp;&gt;]+)', strJunk)
   &gt;&gt;&gt; print match.group(0)
   Value=five
   &gt;&gt;&gt; print match.group(1)
   five
  </code></pre>
  
  <p>How come match.group(0) is the whole thing 'Value=five' and group(1) is just 'five'?  And is there a way for me to just get 'five' as the only result?  (This question stems from me only having a tenuous grasp of regex)</p>
  
  <p>I am also going to have to make a substitution in this string such such as the following:</p>
  
  <pre><code> val1 = match.group(1)
   strJunk.replace(val1, "six", 1)    
  </code></pre>
  
  <p>Which yields:</p>
  
  <pre><code> 'asdf2adsf29Value=six&amp;lakl23ljk43asdldl'
  </code></pre>
  
  <p>Considering that I plan on performing the above two tasks (finding the string between 'Value=' and '&amp;', as well as replacing that value) over and over, I was wondering if there are any other more efficient ways of looking for the substring and replacing it in the original string.  I'm fine sticking with what I've got but I just want to make sure that I'm not taking up more time than I have to be if better methods are out there.  </p>