title: Ruby - extracting table values
body: <p>I'm trying to parse a value from an HTML table (below) using ruby, watir and regular expressions. I want to parse the id info from the anchor tag if the table rows have specified values. For example, if Event1, Action2 are my target row selections, then my goal is to get the "edit_#" for the table row. </p>
  
  <pre><code>Table:
  Event1 | Action2 
  Event2 | Action3 
  Event3 | Action4 
  </code></pre>
  
  <p>Example of HTML (I've cut some info out since this is work code, hopefully you get the idea):</p>
  
  <pre><code>&lt;div id="table1"&gt;
    &lt;table class="table1" cellspacing="0"&gt;
     &lt;tbody&gt;
        &lt;tr&gt;
        &lt;tr class="normal"&gt;
            &lt;td&gt;Event1&lt;/td&gt;
            &lt;td&gt;Action2&lt;/td&gt;
            &lt;td&gt;
            &lt;a id="edit_3162" blah blah blah… &gt;
            &lt;/a&gt;
            &lt;/td&gt;
       &lt;/tr&gt;
         &lt;tr class="alt"&gt;
            &lt;td&gt; Event2&lt;/td&gt;
            &lt;td&gt;Action3 &lt;/td&gt;
            &lt;td&gt;
            &lt;a id="edit_3163" " blah blah blah…&gt;
            &lt;/a&gt;  
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have tried the following that doesn't really work:</p>
  
  <pre><code>wb=Watir::Browser.new
  wb.goto "myURLtoSomepage"
  event = "Event1"
  action = "Action2"
  table = browser.div(:id, "table1")
  policy_row = table.trs(:text, /#{event}#{action/)
  puts policy_row
  policy_id = policy_row.html.match(/edit_(\d*)/)[1]
  puts policy_id
  </code></pre>
  
  <p>This results in this error which is pointing to the policy_id = ... 
  line : <code>undefined method 'html' for #&lt;Watir::TableRowCollection:0x000000029478f0&gt; (NoMethodError)</code></p>
  
  <p>Any help is appreciated as I am fairly new to ruby and watir.</p>