Nuv Posted March 16, 2011 Share Posted March 16, 2011 I am trying to capture the href link from one of the sites.The part of the source code is as follows <tr bgcolor="#CCCCCC"> <td align=right></td> <td align=center valign=center width=10><a href="/info/link1"> I am using preg_match_all('~<tr\sbgcolor="#CCCCCC">\s<td\salign=right></td>\s<td\salign=center\svalign=center\swidth=10><a\shref="(.*)">\siU~', $data, $link); However $link isn't storing anything. Is my regex right ? Quote Link to comment Share on other sites More sharing options...
sasa Posted March 16, 2011 Share Posted March 16, 2011 preg_match_all('~<tr\sbgcolor="#CCCCCC">\s*<td\salign=right></td>\s*<td\salign=center\svalign=center\swidth=10><a\shref="(.*?)">~siU', $data, $link); Quote Link to comment Share on other sites More sharing options...
Nuv Posted March 16, 2011 Author Share Posted March 16, 2011 Added + after ever \s to make it something like <a\s+href="(.*?)"> and it worked. Quote Link to comment Share on other sites More sharing options...
Nuv Posted March 16, 2011 Author Share Posted March 16, 2011 Thankyou sasa. I figured that out after reading couple of sites. 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.