title: Replace an underscore separated substring in the middle of a comma separated string
body: <p>I have a file with multiple lines in it like this:</p>
  
  <pre><code> 'AMS_Investigation|txtt.co_BigtittedBlondOtherNight_1371078139195_+14155186442', {'cf:rv': '0'}
  </code></pre>
  
  <p>I want to replace the 1371078139195 (in this case) with another number. 
  The value I want to replace is always in the first comma separated word and is always the second last underscore separated value in that word. 
  The following is the way I did this and it works but this seems unseemly and clumsy.</p>
  
  <pre><code>&gt;&gt;&gt; line="'AMS_Investigation|txtt.co_BigtittedBlondOtherNight_1371078139195_+14155186442', {'cf:rv': '0'}"
  &gt;&gt;&gt; l1=",".join(line.split(",")[1:])
  &gt;&gt;&gt; print l1
   {'cf:rv': '0'}
  &gt;&gt;&gt; l2=line.split(",")[0]
  &gt;&gt;&gt; print l2
  'AMS_Investigation|txtt.co_BigtittedBlondOtherNight_1371078139195_+14155186442'
  &gt;&gt;&gt; print "_".join(l2.split('_')[:-2])
  'AMS_Investigation|txtt.co_BigtittedBlondOtherNight
  &gt;&gt;&gt;
  &gt;&gt;&gt; print "_".join(l2.split('_')[:-2])+ "_1234567_"+(l2.split('_')[-1])
  'AMS_Investigation|txtt.co_BigtittedBlondOtherNight_1234567_+14155186442'
  &gt;&gt;&gt; print "_".join(l2.split('_')[:-2])+ "_1234567_"+(l2.split('_')[-1]) + "," + l1
  'AMS_Investigation|txtt.co_BigtittedBlondOtherNight_1234567_+14155186442', {'cf:rv': '0'}
  &gt;&gt;&gt;
  </code></pre>
  
  <p>Is there an easier way to replace (maybe using regular expressions) the value? I can't imagine that this is the best way</p>
  
  <p>I have a few answers and I have to stress that its the second last underscored value. The following are valid strings:</p>
  
  <pre><code>line = "'AMS_Investigation|txtt.co_23456_BigtittedBlondOtherNight_1371078139195_+14155186442', {'cf:rv': '0'}"
  line = "'AMS_Investigation|txtt.co_23456_BigtittedBlondOtherNight_1371078139195_14155186442', {'cf:rv': '0'}"
  line = "'AMS_Investigation|txtt.co_1371078139195_BigtittedBlondOtherNight_1371078139195_1371078139195', {'cf:rv': '0'}"
  </code></pre>
  
  <p>In the above case there is a digit string within the string that is not after the second last underscore. Also the last part may or may not be all digits (it could be +14155186442 or it could be 14155186442). Sorry I didn't mention this above.</p>
  
  <p>A</p>