title: loop through string to find substring
body: <p>I have this string: </p>
  
  <pre><code>text = "book//title//page/section/para";
  </code></pre>
  
  <p>I want to go through it to find all // and / and their index.</p>
  
  <p>I tried doing this with: </p>
  
  <pre><code>if (text.Contains("//"))
  {
      Console.WriteLine(" // index:  {0}  ", text.IndexOf("//"));   
  }
  if (text.Contains("/"))
  {
      Console.WriteLine("/ index:  {0}  :", text.IndexOf("/"));    
  }
  </code></pre>
  
  <p>I was also thinking about using: </p>
  
  <pre><code>Foreach(char c in text)
  </code></pre>
  
  <p>but it will not work since <code>//</code> is not a single char.</p>
  
  <p>How can I achieve what I want?</p>
  
  <p>I tried this one also but did not display result</p>
  
  <pre><code>string input = "book//title//page/section/para"; 
  string pattern = @"\/\//";
  
  
  Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
  MatchCollection matches = rgx.Matches(input);
   if (matches.Count &gt; 0)
    {
        Console.WriteLine("{0} ({1} matches):", input, matches.Count);
        foreach (Match match in matches)
           Console.WriteLine("   " + input.IndexOf(match.Value));
   }
  </code></pre>
  
  <p>Thank you in advance.</p>