Forum Moderators: coopster
I'm trying to match a pattern using pre_match.
While my match works, I would like to exclude the outside of my match, leaving only the inbetween.
preg_match("/href=\".*\"/isx",$feed[$i],$link);
Current returns:
href=\"http://www.example.com/\"
What I would like to return:
http://www.example.com/
[edited by: eelixduppy at 1:46 am (utc) on Feb. 7, 2008]
Nevermind that, uhm thats quite easy to do... a simple way for me (the way i undestand) would be like this...
a file i had recently done but it can be modified to suit you're needs.
<?php
$artist = urlencode($_GET['artist']);
$url = 'http://www.last.fm/music/'.$artist.'/+wiki';
$file = file_get_contents($url);
$factbook2 ='<div class=\"f\"><span class=\"iesucks\"> </span></div>
</div></div>';
$thatline = '<div style=\"margin-top:20px; border-top:1px solid #CCC; padding-top:10px;\">';
$factbook2 = stripslashes($factbook2);
$factpos2 = strpos($file, $factbook2);
$desc = substr_replace($file, ' ', 0, $factpos2) . '';
$desc = str_replace($factbook2, ' ', $desc);
$thatline = stripslashes($thatline);
$thatlinepos = strpos($desc, $thatline);
$desc = substr_replace($desc, '', $thatlinepos, -1) . "<br />\n";
echo $desc;
?>
[edited by: GamingLoft at 1:59 am (utc) on Feb. 7, 2008]
preg_match("/href=\".*\"/isx",$feed[$i],$link);
preg_match("/href=\"[b]([/b].*[b])[/b]\"/isx",$feed[$i],$link);
As you also use brackets to group things together and you may not want them captured then you can use (?:
(?: group of stuff not to be captured )