SmileyBot 13 Posted June 22, 2013 Report Share Posted June 22, 2013 Hey GuysI have been playing with this for hours, can someone please helpI'm using $replace regular expression to replace the word proxy.phpThe problem I have is the below regex matches both occurrencesand I only want to replace the first occurrence ?<=file_get_contents..)(.*?(?=")) echo (file_get_contents("proxy.php"));echo (file_get_contents("proxy.php"));echo (file_get_contents("proxy.php")); cheers Quote Link to post Share on other sites
UBotDev 276 Posted June 22, 2013 Report Share Posted June 22, 2013 You can always add items to list, loop through it and process one by one. Quote Link to post Share on other sites
VaultBoss 310 Posted June 22, 2013 Report Share Posted June 22, 2013 This code will extract only the LAST occurence: (?<=.*").*\..*(?=".*$) ...otherwise, just like UBotDev.com said above, add everything to a list (so that you eliminate dupes that way and then loop through it and eliminate anything else that doesn't suit your needs. Quote Link to post Share on other sites
Pete 121 Posted June 22, 2013 Report Share Posted June 22, 2013 One way to get the first item is set(#proxy_php, "echo (file_get_contents(\"proxy1.php\")); echo (file_get_contents(\"proxy2.php\")); echo (file_get_contents(\"proxy3.php\"));", "Global") set(#proxy_php, $list item($find regular expression(#proxy_php, "(?<=contents\\(\\\").*?(?=\\\"\\)\\))"), 0), "Global") I've given them numbers just to show it grabs the correct item Quote Link to post Share on other sites
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.