I need to parse the html page for a patern. I am assuming that the matches are loaded into an array. And then I need to output the contents of the array.
<script language="JavaScript" type="text/javascript">
var adBookmarkletData=[
'<html><head><title>MYSA Yahoo! APT Debugger</title></head><body><center><div style=\"background:#ccc;color:#000;width:350px;text-align:left;padding:15px;border:2px #000;\">','<b>MYSA Yahoo! APT Debugger:</b><br /><hr />',
'<b>URL:</b> '+document.location.href+'<br />',
'<b>Pub ID:</b> '+window.yld_mgr.pub_id+'<br />',
'<b>Site Name:</b> '+window.yld_mgr.site_name+'<br />',
'<b>Content Topic ID List:</b> '+window.yld_mgr.content_topic_id_list+'<br />',
'<b>Site Section Name List:</b> '+window.yld_mgr.site_section_name_list+'<br />'
];
for(i in window.yld_mgr.slots){
adBookmarkletData.push('<b>Ad:</b> ('+i+')<b>Category:</b>('+window.yld_mgr.slots[i].cstm_content_cat_list+')<br />');
};
//Here my problem starts
var myRegExp = new RegExp("place_ad_here\('(.*?)'\)");
//Here my Problem ends
adBookmarkletData.push(myRegExp.exec(document.innerHTML));
adBookmarkletData.push('</div></center></body></html>');
function createAptDebugger(){
for (i in adBookmarkletData){
document.write(adBookmarkletData[i]);
}
};
void(createAptDebugger());
</script>
The RegEx pattern works in an online tester against sample code. But the results here are null. I do not get how to direct the RegEx against the html page and then to output it from the array.
For clarity the html will have tags like this in the body.
<script type="text/javascript">yld_mgr.place_ad_here('A728');</script>
<script type="text/javascript">yld_mgr.place_ad_here('ASPON120');</script>
<script type="text/javascript">yld_mgr.place_ad_here('ROLLOVER');</script>
<script type="text/javascript">yld_mgr.place_ad_here('A300');</script>
<script type="text/javascript">yld_mgr.place_ad_here('Middle1');</script>
<script type="text/javascript">yld_mgr.place_ad_here('B300');</script>
The results would look like this:
place_ad_here('A728')
place_ad_here('ASPON120')
place_ad_here('ROLLOVER')
place_ad_here('A300')
place_ad_here('Middle1')
place_ad_here('B300')
Which is pretty much how I want to display them.
Thanks in advance...