i get some HTML it a as ajax response, and i need to get just the body contents. So i made this regex:
/(<body>|<\/body>)/ig
works well in all browser but for some reason IE gives me an other array when i use split:
data.split(/(<body>|<\/body>)/ig)
In all normal browsers the content of the body is split(/(<body>|<\/body>)/ig)[2]
but in ie its in split(/(<body>|<\/body>)/ig)[1]
. (tested in IE7 & 8)
Why is this? And how could i modify it, in order to get the same array in all browsers?
edit just to clarify. I alrady have a solution as mentioned by tobyodavies. I want to understandy, why it behaves differently.
this is the HTML from the response: (the string in data)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de" dir="ltr">
<head>
blablabla...
</head>
<body>
<div class="iframe">
<div id="block-menu-menu-primary-links-user" class="block-menu">
<h3>Primary Links - User</h3> <div class="content"><ul class="menu"><li class="leaf first"><a target="content" href="#someurl" title="">Login</a></li>
<li class="leaf last"><a target="content" href="#someurl" title="">Register</a></li>
</ul></div>
</div>
</div>
</body>
</html>
PS: i know that parsing HTML with regex is bad, but its not my code, i just need to fix it.