Advertisement
Cherry83

07. URL Replacer

Feb 4th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. <?php
  2.  
  3. $input = trim(fgets(STDIN));
  4.  
  5. $replace = preg_replace('/\<a [^>]*?href\s*=\s*\'([^<>\s]*)\'[^\<]*>((\s|.)+?)\<\/a\>/i', "[URL=$1]$2[/URL]", $input);
  6.  
  7. $replace = preg_replace('/\<a [^>]*?href\s*=\s*"([^<>\s]*)"[^\<]*>((\s|.)+?)\<\/a\>/i', "[URL=$1]$2[/URL]", $replace);
  8.  
  9. echo $replace;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement