I'm having one heck of a time trying to match a tag. It looks right to me (and checks out in all of the Regex Tester webapps I've tried) but does not work when I put it to use. The following is the code (with site address and name replaced with "Awesome Site") of the web page, and after that is the Javascript I'm using to try to match it. I am trying to match the Table Cell with the ID "myAlerts". Currently, it alerts null.
<table cellpadding="1" cellspacing="0" width="100%">
<tbody><tr>
<td id="myAlerts">
<a href="/home.php?nc=1"><b>Awesome Site Inc</b> has news.<br></a><a href="/home.php?nc=1"><b>Awesome Site Inc</b> has a comic.<br></a><a href="http://www.awesomesite.com/archive/?nc=1"><b>Awesome Site Inc</b> has a new video.<br></a><a href="/members/messaging/">You have <b>1</b> new message.</a><br><a href="/members/messaging/">You have <b>1</b> new friend request.</a><br><a href="/members/comments/index.php">You have <b>10</b> new personal comments.</a><br><a href="/members/journal/entry.php?id=2059183">You have <b>1</b> new journal comment.</a><br><a href="/members/journal/entry.php?id=2059185">You have <b>1</b> new journal comment.</a><br><a href="/members/images/image.php?id=2239675">You have <b>1</b> new image comment.</a><br><a href="/members/clearAllAlerts.php"><b>Clear all alerts.</b></a> </td>
</tr>
</tbody></table>
function test(){
var response=document.body.innerHTML
var regAlert=/<td id='myAlerts'>\n?(.*?)<\/td>/mi;
alert(response.match(regAlert));
}
Of little note: I am executing this through the Greasemonkey extension for Firefox, so my method of setting the "response" variable is slightly different. In practice, it captures the entire HTML of the page, not just the contents of the Body tag. Also, the alert() is a simple replacement for where I append a DIV to the current page. For the purposes of troubleshooting, that info is irrelevant and I have already tested those components to be sure they're working properly. I'm just stating them here in anticipation that people will want to know what exactly I'm trying to accomplish.