title: getElementsByTagName setAttribute and regex javascript
body: <p>i want to put rel=lightbox to some links that mediabox support using javascript.</p>
  
  <p>i try this and wonder why it's not working? </p>
  
  <p>test: <a href="http://jsbin.com/opica" rel="nofollow noreferrer">http://jsbin.com/opica</a></p>
  
  <p>please help edit this: <a href="http://jsbin.com/opica/edit" rel="nofollow noreferrer">http://jsbin.com/opica/edit</a></p>
  
  <pre><code>&lt;script  type="text/javascript"&gt;
  var x=xmlDoc.getElementsByTagName("a");
  var regexku=/^.+(((twit)|(tweet)|(com/video.+)|(flickr.com.+)|(tube.com.+))|((gif)|(jpe?g)|(png)|(flv)|(swf)|(mp3)|(mp4))$)/;
  
  for(i=0;i&lt;x.length;i++)
   {
  a=x[i].getAttribute('href');
  if (a.match(regexku) != null)
     {
     x.item(i).setAttribute("rel","lightbox");
     }
   }
  
  &lt;/script&gt;
  </code></pre>