Airhead315 Posted May 7, 2007 Share Posted May 7, 2007 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:someguy@somesite.com ">someguy@somesite.com </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); Quote Link to comment Share on other sites More sharing options...
Wildbug Posted May 8, 2007 Share Posted May 8, 2007 I would use this: preg_match("/<b>Posted by:<\/b>(.*?)<BR>/is", $parts[$i],$innerparts); It looks like you've got newlines in your input, and the dot metacharacter won't match newlines unless you give it permission in the form of the /s modifier. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.