title: How do you retrieve selected text using Regex in C#?
body: <p>How do you retrieve selected text using Regex in C#?</p>
  
  <p>I am looking for C# code that is equivalent to this Perl code:</p>
  
  <pre><code>$indexVal = 0;
  if($string =~ /Index: (\d*)/){$indexVal = $1;}
  </code></pre>