Javascript regular expression: match()


<input type="button" value="Match" onclick="javascript:demo('hello world');return false;" />
&nbsp;&nbsp;&nbsp;
<input type="button" value="No Match" onclick="javascript:demo('hello warld');return false;" />

<script type="text/javascript" language="JavaScript">
//<![CDATA[
   function demo(text) {
      var re = /wo(rl)d/i;
      var found = text.match(re);
      if (found != null && found.length > 0) {
         alert("found = " + found);
         for(i=0;i<found.length;i++){
            alert("found[" + i + "]= " + found[i]);
         }
      } else {
         alert("no match");
      }
   }
//]]>
</script>