Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. preg_replace("%(?<=[?&])$param=.+(&|$)%", '', $url);
  2.  
  3. $string = 'https://www.google.com/search?q=Metallica+Turn+The+Page&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb';
  4.  
  5. $string = preg_replace('~?.*~', '', $string);
  6.  
  7. print $string;
  8.  
  9. https://www.google.com/search
  10.  
  11. // REPLACE ALL OF THE PARAMS WITH DUMMY-PARAM
  12. $string = 'https://www.google.com/search?q=Metallica+Turn+The+Page&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb';
  13.  
  14. $string = preg_replace('~[?&]K([A-Z0-9+%]+)=.+?(?=&|$)~i', '$1=DUMMY-PARAM', $string);
  15.  
  16. print "nn".$string;
  17.  
  18. // REPLACE ALL OF THE KEYS WITH DUMMY-KEY
  19. $string = 'https://www.google.com/search?q=Metallica+Turn+The+Page&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb';
  20.  
  21. $string = preg_replace('~[?&]K[A-Z0-9+%]+=(.+?)(?=&|$)~i', 'DUMMY-KEY=$1', $string);
  22.  
  23. print "nn".$string;
  24.  
  25. // PULL OUT ALL KEYS/VALUES
  26. $string = 'https://www.google.com/search?q=Metallica+Turn+The+Page&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb';
  27.  
  28. $string = preg_replace('~[?&]K([A-Z0-9+%]+)=(.+?)(?=&|$)~i', "n$1: $2", $string);
  29.  
  30. print "nn".$string;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement