title: C# IndexOf function not working as expected
body: <p>So, I'm fairly new to coding, but I've never had a problem with IndexOf until now. I'm trying to search through an html string which looks like:</p>
  
  <blockquote>
    <p>" data-pid=\"6598160343\">\n\n        https://minneapolis.craigslist.org/dak/fuo/d/executive-desk-3-piece-set/6598160343.html\"
    class=\"result-image gallery\"
    data-ids=\"1:00B0B_hkRi5TEyM9Q,1:00z0z_jTtBxHxlxAZ,1:00p0p_2GU15WOHDEB,1:00909_eKQVd7O1pfE\">\n
    $1500\n        \n\n    \n        \n            favorite this post\n<br>
    \n\n            Jun 
    4\n\n\n        https://minneapolis.craigslist.org/dak/fuo/d/executive-desk-3-piece-set/6598160343.html\"
    data-id=\"6598160343\" class=\"result-title hdrlnk\">Executive Desk (3
    piece set)\n\n\n        \n<br>
    $1500\n\n\n\n                \n                    pic\n<br>
    map\n<br>
    \n\n                \n                    hide this posting\n<br>
    \n\n            \n            \n                restore\n                restore this posting\n<br>
    \n\n        \n    </p>\n</li>\n         "  string</p>
  </blockquote>
  
  <p>I'm trying to find the index of specific elements so that I can grab the data later, here's what I have to find the indexes of the positions on either side of the data I want:</p>
  
  <pre><code>DataBookends bkEnds = new DataBookends
          {
              PIDFrom = (post.IndexOf(@"pid=\""")) + (@"pid=\""".Length),
              URLFrom = (post.IndexOf(@"&lt;a href=\")) + (@"&lt;a href=\".Length),
              PriceFrom = (post.IndexOf(@"result-price\""&gt;$")) + (@"result-price\""&gt;$".Length),
              DateFrom = (post.IndexOf(@"datetime=\""")) + (@"datetime=\""".Length),
              TitleFrom = (post.IndexOf(@"result-title hdrlnk\""&gt;")) + (@"result-title hdrlnk\""&gt;".Length),
              LocationFrom = (post.IndexOf(@"result-hood\""&gt; (")) + (@"result-hood\""&gt; (".Length)
          };
          bkEnds.PIDTo = post.IndexOf(@"\""", bkEnds.PIDFrom);
          bkEnds.URLTo = post.IndexOf(@"\", bkEnds.URLFrom);
          bkEnds.PriceTo = post.IndexOf(@"&lt;/span&gt;", bkEnds.PriceFrom);
          bkEnds.DateTo = post.IndexOf(@"\", bkEnds.DateFrom);
          bkEnds.TitleTo = post.IndexOf(@"&lt;/a&gt;", bkEnds.TitleTo);
          bkEnds.LocationTo = post.IndexOf(@"\", bkEnds.LocationFrom);
  
          return bkEnds;
  </code></pre>
  
  <p>However, whenever I try to run it, it either doesn't find anything, or the index values are incorrect. I know I'm missing something simple but I can't figure it out and I feel like a moron. Is it something to do with escape characters I'm not seeing or something with how my string is formatted?
  Help please?</p>
  
  <p>EDIT:
  I initially tried using the HTML Agility Pack, but I was having trouble understanding how to extract the data I needed so I thought using string.substring() would've been more straightforward.
  The index values I'm getting are entirely wrong, even before I tried adding the forward-slashes. I'll be getting rid of those.</p>