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? Quote 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? Quote 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 Quote 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 Quote 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> Quote 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). Quote Link to comment https://forums.phpfreaks.com/topic/169158-solved-preg_match/#findComment-892576 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.