ikin Posted October 25, 2010 Share Posted October 25, 2010 Well I'm stuck... So I'm trying to make the php print out the text between title="Text here" <?php function Betweens($string) { $pattern = '/title="(.*?)"/'; //It fails here preg_match($pattern, $string, $matches); return $matches[1]; } $str = '<iu pageid="2022" ns="0" title="Test" />'; $p = Betweens($str); echo $p; ?> So yea I really suck at regex's.. Edit: God damn it, now I see I've posted in wrong sector -.- Link to comment https://forums.phpfreaks.com/topic/216801-regex-help/ Share on other sites More sharing options...
The Little Guy Posted October 25, 2010 Share Posted October 25, 2010 it works for me. When I run that I see the word Test Link to comment https://forums.phpfreaks.com/topic/216801-regex-help/#findComment-1126375 Share on other sites More sharing options...
tastro Posted October 25, 2010 Share Posted October 25, 2010 replace this: $pattern = '/title="(.*?)"/'; //It fails here with this: $pattern = '/title\=\"(.*?)\"/i'; //It fails here and if this doesn't work... then try to change the \" to \' best regards, tastro Link to comment https://forums.phpfreaks.com/topic/216801-regex-help/#findComment-1126378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.