kevinkhan Posted October 21, 2011 Share Posted October 21, 2011 I want to extract the name within the anchor tag of the following code takin from a source file. Has worked at <a href="http://www.facebook.com/pages/Bridewell-bar/110926698934250" data-hovercard="/ajax/hovercard/page.php?id=110926698934250">Bridewell bar</a> is there anyway i can remove all the code before "Has worked at" and use the code below to extract the name $page is full source code of page include('simple_html_dom.php'); code to remove every thing before "Has worked at" $job = str_get_html($page); $job = $jobd->find(' next <a> tag',0); $job = $job->value; Any ideas and can somebody help me write the code. iv tryed using strpos function but can figure it out Link to comment https://forums.phpfreaks.com/topic/249522-regex-and-simple_html_dom-to-extract-a-visible-text-in-an-anchor-tag/ Share on other sites More sharing options...
MarPlo Posted October 22, 2011 Share Posted October 22, 2011 Hi, Try use this example: $str = 'SOme contennt - Has worked at <a href="http://www.facebook.com/pages/Bridewell-bar/110926698934250" data-hovercard="/ajax/hovercard/page.php?id=110926698934250">Bridewell bar</a>'; $regxp = '/Has worked at \<(.*)\>(.*?)\</i'; if(preg_match($regxp, $str, $re)) { echo $re[2]; // Bridewell bar } Link to comment https://forums.phpfreaks.com/topic/249522-regex-and-simple_html_dom-to-extract-a-visible-text-in-an-anchor-tag/#findComment-1281377 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.