I am not good when using preg_match function
but I am trying to use it to find the first body tag.
the tag could be in any of the following formats
<body class="blah">
<body style="blah: blahblah;">
<body>
I was able to use preg_match() to get the first and the second example. But, it is not working on the last example. a simple <body>
is not found.
Here is what I have done. $message
is the string that I am trying to parse
$foundBody = preg_match('/<body(.*)>/i',$message, $bodyf);
if($foundBody != false){
$strPos = strpos($message, $bodyf[0]);
echo $strPos .'<br><br>';
echo $bodyf[0] . '<br><br>';
echo strlen($bodyf[0]) . '<br><br>';
if($strPos !== false){
$message = substr($message, $strPos + strlen($bodyf[0]) );
}
}
NOTE: I am not prying to parse an html code. All I am trying to go here is to parse an email. I basically want to return a text begins immediately after <body....>
tag to the end of the string.