title: Python: How to move the position of an output variable using the split() method
body: <p>This is my first SO post, so go easy! I have a script that counts how many matches occur in a string named <em>postIdent</em> for the substring  <em>ff</em>. Based on this it then iterates over <em>postIdent</em> and extracts all of the data following it, like so:</p>
  
  <pre><code>substring = 'ff'
  global occurences
  occurences = postIdent.count(substring)
  
  x = 0
      while x &lt;= occurences:
          for i in postIdent.split("ff"):
              rawData = i
              required_Id = rawData[-8:]
              x += 1
  </code></pre>
  
  <p>To explain further, if we take the string "090fd0909a9090<strong>ff</strong>90493090434390<strong>ff</strong>90904210412419ghfsdfs9000<strong>ff</strong>", it is clear there are 3 instances of <strong>ff</strong>. I need to get the 8 preceding characters at every instance of the substring <em>ff</em>, so for the first instance this would be <em>909a9090</em>.
  With the <em>rawData</em>, I essentially need to offset the variable <em>required_Id</em> by -1 when I get the data out of the split() method, as I am currently getting the last 8 characters of the current string, not the string I have just split. Another way of doing it could be to pass the current <em>required_Id</em> to the next iteration, but I've not been able to do this.</p>
  
  <p>The split method gets everything <strong>after</strong> the matching string <em>ff</em>. 
  Using the partition method can get me the data I need, but does not allow me to iterate over the string in the same way.</p>