SHARE
TWEET

Untitled

a guest Feb 19th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function removeUrl($string='', $replace_with='URL HIDDEN', $allowed_domains=null){
  2.     $string = str_replace('....', '.', $string);
  3.     $string = str_replace('...', '.', $string);
  4.     $string = str_replace('..', '.', $string);
  5.     $string = preg_replace('/(\d)\.([a-z]{2,3})/', '$1. $2', $string);
  6.     $string = preg_replace_callback('@((https?://)?([-\w]+\.[-\w\.][^\/0-9\-]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@', function($match) use($replace_with, $allowed_domains){
  7.         // Allowed domains
  8.         if(strpos($match[0], '...') !== false){
  9.             return $match[0];
  10.         }
  11.         // Return replaced string
  12.         return ' ['.strtoupper($replace_with).'] ';
  13.     }, $string);
  14.     return $string;
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top