Javascript regular expression: a|b |
<input type="button" value="Match1" onclick="javascript:demo('help');return false;" /> <input type="button" value="Match2" onclick="javascript:demo('halp');return false;" /> <input type="button" value="No Match" onclick="javascript:demo('hulp');return false;" /> <script type="text/javascript" language="JavaScript"> //<![CDATA[ function demo(text) { var re = /he|alp/; if (text.match(re)) { alert("match"); } else { alert("no match"); } } //]]> </script> |