title: Regex - Find elements with name attribute but not id
body: <p>This problem came to me today. I'm working in a web-based (Struts 2) project with lots of JSPs, and most of <code>input, select, table</code> and <code>a</code> elements are defined with only with the <code>name</code> attribute, no <code>id</code> set, such as:</p>
  
  <p><code>&lt;input name="myname" class="myclass" value="" type="text"/&gt;</code> </p>
  
  <p>So far so good, except that unfortunately there's a lot of javascript validation for those fields, and as far as I could read the code before leaving most of them actually refer to the elements with <code>document.getElementById</code>.</p>
  
  <p>The catch here is that this is an old application (not that much old actually) only compatible with IE-6 and IE-7 (I didn't searched the net in order to understand how IE actually seems to find the element only with the <code>name</code> attribute, but I guess it must do something). No surprise every other single browser complains and cries.</p>
  
  <p>So, I'm trying to come up with a simple solution: look up all JSPs that defines <code>input, select, table</code> and <code>a</code> elements with the <code>name</code> attribute but not <code>id</code> in order to fix the HTML.</p>
  
  <p>Using my good ol' friend <a href="http://rubular.com" rel="nofollow">http://rubular.com</a> I came up with the following:</p>
  
  <p><code>/&lt;(?:(input|select|a|table))\s+((?!id).)*&gt;</code></p>
  
  <p>This will catch every referred element without <code>id</code>. But how can I actually assert that only those with <code>name</code> are matched?</p>
  
  <p>Oh, another important point. The definition of the elements are in a single line, so it's most probable that there arent't such things as:</p>
  
  <pre><code>&lt;input name="..."
         class="..."/&gt;
  </code></pre>