JavaScript之正則表達式入门

<html>
<head><title>Js String 正則表達式</title>
<script>
//边界符 js 中直接定义须要边界符//  java里面不须要边界符
var re = /abc/;//匹配abc的
document.write(re.test("abcdabc")+","+re.test("XXXC")+"<br/>");
re =/\/abc\//;
//匹配/abc/
document.write(re.test("/abc/")+","+re.test("addd")+","+"<br/>");
//不须要边界符
//匹配abc的
var regex = new RegExp("abc");
document.write(regex.test("abc")+","+regex.test("abcdeabc")+","+regex.test("xxxxadcabcc")+"<br/>");

</script>

</head>
<body>
</body>
</html>





































posted @ 2018-04-09 17:17  llguanli  阅读(83)  评论(0编辑  收藏  举报