title: How to get last string in TStringList
body: <p>I've been searching for days on how to do this, and nothing is exactly what I need to do (or I just don't understand how to implement the solution).</p>
  
  <p>What I need to do is parse a string, which is a street address, into a TStringList, and then set those strings from the list to variables I can then pass to the rest of the program. I already have the list working ok:</p>
  
  <pre><code>var
  AddressList : TStringList;
  i : integer;
  
  begin
  AddressList := TStringList.Create;
  AddressList.Delimiter := ' ';
  AddressList.DelimitedText := RawAddressStr; //RawAddressStr is parsed from another file and the string result is something like '1234 Dark Souls Lane Wyoming, MI 48419'
  
  for i := 0 to AddressList.Count-1 do
     AddressList.Strings[i]; //Not sure what to do here
  </code></pre>
  
  <p>The issue is that the address isn't always the same length. The address will sometimes be like '1234 Dark Souls Two Lane Wyoming...' or '1234 Dark Lane Wyoming...'</p>
  
  <p>So I need to be able to use this TStringList to set the Zip, State and City into variables for later use. I would use TStringList.Find, but the ZIP code isn't always the same. Is there a way to get the last string and then go backwards from there? (Going backwards because once I get the City, State ZIP I can remove that from the RawAddressStr and then set the rest to the address string.)</p>
  
  <p>Thanks.</p>
  
  <p>Edit, here's the code I needed (thanks to below comments):
      AddressList := TStringList.Create;</p>
  
  <pre><code>AddressList.Delimiter := ' ';
  AddressList.DelimitedText := RawAddressStr;
  
  for i := 0 to AddressList.Count-1 do
    LastIndex := AddressList.Count - 1;
    ZipStr := AddressList[LastIndex];
    StateStr := AddressList[LastIndex - 1];
    CityStr := AddressList[LastIndex - 2];
  </code></pre>
  
  <p>Now I can use these with StringReplace to take out the City, State Zip from the full address string, and set that as the Address string to use.</p>