Javascript regular expression: \s |
<input type="button" value="Match1" onclick="javascript:demo('aaa bbb');return false;" /> <input type="button" value="Match2" onclick="javascript:demo('aaa\tbbb');return false;" /> <input type="button" value="No Match1" onclick="javascript:demo('aaa bbb');return false;" /> <input type="button" value="No Match2" onclick="javascript:demo('aaa\t\tbbb');return false;" /> <script type="text/javascript" language="JavaScript"> //<![CDATA[ function demo(text) { var re = /aaa\sbbb/; if (text.match(re)) { alert("match"); } else { alert("no match"); } } //]]> </script> |