时间:2021-07-01 10:21:17 帮助过:56人阅读
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>
How,are,you,doing,today?
H,o,w, ,a,r,e, ,y,o,u, ,d,o,i,n,g, ,t,o,d,a,y,?
How,are,you