Hello, I am programming using php language and I want to find using regex the STRING inside the following: target="">STRING</a> What is the regex code to extract this string? I am using preg_match_all("$re", $html, $m, PREG_PATTERN_ORDER); where $re is the regex code I need. thanks.
You said you wanted to find just the STRING part... $re = '/target=\'"([^\'"]+)\'"[^>]*>([^<]+)<\/a>/i';
Here is one of my old function. (Returns the found results in array) function preg_match_all_array($startWith, $endWith, $source) { $findMatches = preg_match_all('/'.$startWith.'(.*?)'.$endWith.'/si',$source,$matches); if($findMatches) { $allmatches = array(); for($i=0;$i<count($matches[0]);$i++) { $allmatches[] = $matches[1][$i]; } return $allmatches; } else { return false; } } PHP: Here is example usage (this will extract all links from Forums.digitalpoint.com) <?php $get_source = file_get_contents('http://forums.digitalpoint.com/'); $result = preg_match_all_array('href="', '"', $get_source); echo '<pre>'; print_r($result); ?> PHP: