<input type="text" id="txt" /> <input type="button" onclick="check()" value="检测输入"/> <script> function check(){ var reg=/[A-Za-z]/g; var input=document.getElementById("txt").value; var result=input.replace(reg,""); alert(result); } </script>
<script language="JavaScript" type="text/javascript"> var a='asdfas123^dfa123' alert(a.replace(/[a-z]/gi,"")) </script>
标签:replace,正则,过滤,result,alert,var,js,reg From: https://www.cnblogs.com/wangshengli520/p/16601459.html