Javascript regular expression: \w


<input type="button" value="Match1" onclick="javascript:demo('a');return false;" />
&nbsp;&nbsp;&nbsp;
<input type="button" value="Match2" onclick="javascript:demo('aa');return false;" />
&nbsp;&nbsp;&nbsp;
<input type="button" value="Match3" onclick="javascript:demo('ab_12');return false;" />
&nbsp;&nbsp;&nbsp;
<input type="button" value="Match4" onclick="javascript:demo('[email protected]#');return false;" />
<br /><br />
<input type="button" value="No Match1" onclick="javascript:demo('#');return false;" />
&nbsp;&nbsp;&nbsp;
<input type="button" value="No Match2" onclick="javascript:demo('##');return false;" />
&nbsp;&nbsp;&nbsp;
<input type="button" value="No Match3" onclick="javascript:demo('! @#\$%\^&\*\(\)\-\+=~:;<>,.|\{\}\[\]/');return false;" />

<script type="text/javascript" language="JavaScript">
//<![CDATA[
   function demo(text) {
      var re = /\w/;
      if (text.match(re)) {
         alert("match");
      } else {
         alert("no match");
      }
   }
//]]>
</script>