kla0005 Posted February 11, 2010 Share Posted February 11, 2010 Hellow guys, I have made a script that can get the html of other pages, but know i want the <body> name.. I can just take <body> because sometimes the pages have f.eks, a onload="" in it or something, so i tryed this: $body = preg_replace("/\\<body\(.+?)\>/is",'<body \1 >', $code); But that didnt work? What have i done wrong? Please help Link to comment https://forums.phpfreaks.com/topic/191750-preg_match/ Share on other sites More sharing options...
JAY6390 Posted February 11, 2010 Share Posted February 11, 2010 The regex will be /<body\b([^>]*)>/is Link to comment https://forums.phpfreaks.com/topic/191750-preg_match/#findComment-1010685 Share on other sites More sharing options...
cags Posted February 11, 2010 Share Posted February 11, 2010 The regex will be /<body\b([^>]*)>/is Actually the OP wants the contents of the body tag, not the actual opening body tag. The sensible solution is to use DOMDocument or some such similar parsing technology. Link to comment https://forums.phpfreaks.com/topic/191750-preg_match/#findComment-1010713 Share on other sites More sharing options...
JAY6390 Posted February 11, 2010 Share Posted February 11, 2010 Ah oops, missed that yes in that case DOM would be far superior Link to comment https://forums.phpfreaks.com/topic/191750-preg_match/#findComment-1010714 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.