supermerc Posted August 6, 2009 Share Posted August 6, 2009 hey, Im using curl to get a page and somewhere on the page it says formraid.php?target=M615&h=1019c65257c6dd2ec4200602e83369c4 I want to do a preg_match that will get everything after formraid.php?target= so for that example id need M615&h=1019c65257c6dd2ec4200602e83369c4 anyone know how to do that? Link to comment https://forums.phpfreaks.com/topic/169158-solved-preg_match/ Share on other sites More sharing options...
smerny Posted August 6, 2009 Share Posted August 6, 2009 could you do a preg_replace to change "formraid.php?target=" to "" instead? or is "formraid.php?target=" just an example? Link to comment https://forums.phpfreaks.com/topic/169158-solved-preg_match/#findComment-892551 Share on other sites More sharing options...
supermerc Posted August 6, 2009 Author Share Posted August 6, 2009 I dont understand what you are saying Link to comment https://forums.phpfreaks.com/topic/169158-solved-preg_match/#findComment-892553 Share on other sites More sharing options...
thebadbad Posted August 6, 2009 Share Posted August 6, 2009 The pattern could depend on what comes after the snippet you're looking for. Please provide Link to comment https://forums.phpfreaks.com/topic/169158-solved-preg_match/#findComment-892567 Share on other sites More sharing options...
supermerc Posted August 6, 2009 Author Share Posted August 6, 2009 <div style="border-bottom:1px solid black;"> <a href="formraid.php?target=M615&h=a845528fd557c16535ff045a084cabc8"><img align="right" border="0" alt="Attack!" src="images/raidz.jpg" onmouseover="popup(event,'Form new raid!');" onMouseOut="kill();"></a> <a href="/mob.php?id=8048&h=a845528fd557c16535ff045a084cabc8" ONMOUSEOVER="popup(event,'<b>Last killed by</b>: †Noc Supremacy†')" ONMOUSEOUT="kill()"><font color="#009900">King Ashnar, Lord of the Unliving [275]</font></a> </div> Link to comment https://forums.phpfreaks.com/topic/169158-solved-preg_match/#findComment-892568 Share on other sites More sharing options...
thebadbad Posted August 6, 2009 Share Posted August 6, 2009 preg_match('~formraid\.php\?target=([^"]+)~', $source, $matches); echo $matches[1]; Note that I escaped the characters with special regex meaning (the dot and the question mark). Link to comment https://forums.phpfreaks.com/topic/169158-solved-preg_match/#findComment-892576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.