检查一下代码
来源:2-7 编程练习
weixin_慕的地5241954
2019-09-23 05:38:04
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>正则表达式</title>
</head>
<body>
<script type="text/javascript">
var str = 'reguLar expression = regexp';
/*此处写代码*/
// pattern 样板、范例的意思
var pattern = /lar exp/i;
// console.log(pattern.test(str))
// console.log(pattern.exec(str))
var pattern1 = new RegExp('lar exp', 'i')
// console.log(pattern1.test(str))
// console.log(pattern1.exec(str))
document.write(pattern.test(str) + '/' + pattern.exec(str) + '/' + pattern1.test(str) + '/' + pattern1.exec(str) + '/')
</script>
</body>
</html>1回答
同学你好,代码正确,效果实现的不错, 继续加油哦
欢迎采纳,祝学习愉快~~~
相似问题