Jump to content

Help parsing HTML


Airhead315

Recommended Posts

Im having probably the most rediculous problems with the simplest regular expression ever. Here is the code im trying to parse out of:

<B>Original Message:</B>
<P>
<b>Posted by:</b> someguys name
  (<a href="mailto:[email protected]
">[email protected]
</a>)<BR>
<b>Organization:</b><a href="http://www.somesite.com
">JAQUET Ltd
</a> <BR><b>Date posted:</b> Thu Jan 14  5:23:11 US/Eastern 2001
<br>
<b>Subject:</b> some subject of a forum
<br>
<b>Message:</b><br> some long message that has no html tags in it
no breaks and no other weird charachters

 

I tried getting just one part of the meta data I wanted with the following code

preg_match("/<b>Posted by:<\/b>(.*)<BR>/i", $parts[$i],$innerparts);
echo $innerparts[1];

 

As you can see im trying to get the Name/Email of the user who posted the message. However im not getting anything back("Undefined offset: 1")

 

$parts[$i] holds the content shown above.

 

I also tried the following lines with the same result

preg_match("/\<b\>Posted by:\<\/b\>(.*)\<BR\>/i", $parts[$i],$innerparts);

preg_match("/<b>Posted by:<\/b>(.*?)<BR>/i", $parts[$i],$innerparts);

preg_match("/<b>Posted by:<\/b>(.*?)<BR>/i", $parts[$i],$innerparts);

Link to comment
https://forums.phpfreaks.com/topic/50401-help-parsing-html/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.