js字符串方法match()

来源:互联网 发布:uc聊天室最新版本mac 编辑:程序博客网 时间:2024/06/05 18:12
//例子var str="我的大家啊宽带连接";document.write(str.match(/我(.{1,100})啊/g));这里写代码片 //输出 我的大家啊//注意这里的正则表达式,意思是匹配我到啊之间的内容最少1次,最大100次  /我(.{1,100})啊/g
var targetText=$('#myDiv').html();//需要匹配的字符串var matches = targetText.match(/<script(.+)<\/script>/g);//匹配<script>标签console.log(matches);//输出所有<script>的内容
阅读全文
0 0
原创粉丝点击