title: Extract numbers between brackets within a string
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8613237/extract-info-inside-all-parenthesis-in-r-regex">Extract info inside all parenthesis in R (regex)</a>  </p>
  </blockquote>
  
  
  
  <p>I inported data from excel and one cell consists of these long strings that contain number and letters, is there a way to extract only the numbers from that string and store it in a new variable? Unfortunately, some of the entries have two sets of brackets and I would only want the second one? Could I use grep for that?</p>
  
  <p>the strings look more or less like this, the length of the strings vary however:</p>
  
  <pre><code>"East Kootenay C (5901035) RDA 01011"
  </code></pre>
  
  <p>or like this:</p>
  
  <pre><code>"Thompson-Nicola J (Copper Desert Country) (5933039) RDA 02020"
  </code></pre>
  
  <p>All I want from this is <code>5901035</code> and <code>5933039</code></p>
  
  <p>Any hints and help would be greatly appreciated.</p>