在html里面加正则表达式,正则表达式 - 如何解析模式的HTML页面(在JavaScript中)

我需要解析一个模板的html页面。我假设匹配被加载到一个数组中。然后我需要输出数组的内容。

var adBookmarkletData=[

'

MYSA Yahoo! APT Debugger
',' MYSA Yahoo! APT Debugger:
',

'URL: '+document.location.href+'
',

'Pub ID: '+window.yld_mgr.pub_id+'
',

'Site Name: '+window.yld_mgr.site_name+'
',

'Content Topic ID List: '+window.yld_mgr.content_topic_id_list+'
',

'Site Section Name List: '+window.yld_mgr.site_section_name_list+'
'

];

for(i in window.yld_mgr.slots){

adBookmarkletData.push('Ad: ('+i+')Category:('+window.yld_mgr.slots[i].cstm_content_cat_list+')
');

};

//Here my problem starts

var myRegExp = new RegExp("place_ad_here\('(.*?)'\)");

//Here my Problem ends

adBookmarkletData.push(myRegExp.exec(document.innerHTML));

adBookmarkletData.push('

');

function createAptDebugger(){

for (i in adBookmarkletData){

document.write(adBookmarkletData[i]);

}

};

void(createAptDebugger());

RegEx模式适用于针对示例代码的在线测试程序。但是这里的结果是空的。我不知道如何将RegEx指向html页面,然后从数组中输出。

为了清晰起见,html在body中会有这样的标签。

结果如下所示:

place_ad_here('A728')

place_ad_here('ASPON120')

place_ad_here('ROLLOVER')

place_ad_here('A300')

place_ad_here('Middle1')

place_ad_here('B300')这几乎是我想要显示它们的方式。

提前致谢...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值