这样可以吗
来源:3-19 编程练习
我叫壹陆伍
2021-07-29 21:40:20
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>正则表达式</title>
</head>
<body>
<script type="text/javascript">
str="cctv have [cctv1]、[cctv2]、[cctv3]、[cctv4]……";
/*此处添加代码*/
var pattern=/\[\w+?\]/;
var pattern1=/\[\w\w\w\w\w]/;
console.log(pattern.exec(str));
console.log(pattern1.exec(str));
</script>
</body>
</html>
1回答
好帮手慕星星
2021-07-30
同学你好,这两种正则写法都是可以的 ,很棒哦。
祝学习愉快!
相似问题