function checkForm() { var u = document.form_name.check.value; var s = /^[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)*@[-a-zA-Z0-9_]+(\.[-a-zA-Z0-9_]+)*$/; var a = s.exec(u); var a = s.test(u); var a = u.match(s); var a = u.search(s); alert(a); }
replace
最简单的算是能力就是简单的字符替换。示例代码如下:
复制代码 代码如下:
var u = "javascript is a good script language"; //在此我想将字母a替换成字母A var s = /a/g; var a = u.replace(s,"A"); /script>
split
复制代码 代码如下:
script type="text/javascript"> var str="How are you doing today?" document.write(str.split(" ") + "br />") document.write(str.split("") + "br />") document.write(str.split(" ",3)) /script>