title: Remove last occurrence of a string in a string
body: <p>I have a string that is of nature</p>
  
  <ul>
  <li>RTT(50)</li>
  <li>RTT(A)(50)</li>
  <li>RTT(A)(B)(C)(50)</li>
  </ul>
  
  <p>What I want to is to remove the last () occurrence from the string. That is if the string is - RTT(50), then I want RTT only returned. If it is RTT(A)(50), I want RTT(A) returned etc.</p>
  
  <p>How do I achieve this? I currently use a substring method that takes out any occurrence of the () regardless. I thought of using: </p>
  
  <pre><code>Regex.Matches(node.Text, "( )").Count
  </code></pre>
  
  <p>To count the number of occurrences so I did something like below.</p>
  
  <pre><code> if(Regex.Matches(node.Text, "( )").Count &gt; 1)
        //value = node.Text.Remove(Regex.//Substring(1, node.Text.IndexOf(" ("));
   else
       value = node.Text.Substring(0, node.Text.IndexOf(" ("));
  </code></pre>
  
  <p>The else part will do what I want. However, how to remove the last occurrence in the if part is where I am stuck.</p>