fork download
  1. <?php
  2.  
  3. $re = '~(?x)\b # Word boundary
  4. (?! # Exclusion list
  5. [A-Z](?:\.[A-Z])+\b # No upper and 1+ sequences of . + an upper
  6. | # or
  7. \d+(?:\.\d+)+\S+\b # digits + 1+ dot and digits and 1+ non-whitespaces
  8. )
  9. (?:https?://)? # Optional http / https protocol part
  10. (?:[-\w]+\.[-\w.]+)+ # 1+ sequences of 1+ - or word chars, then . and 1+ -, ., or word chars
  11. \w(?::\d+)? # word char and 1 optional sequence of : and 1+ digits
  12. (?:/(?:[-\w/.]*(?:\?\S+)?)?)* # 0+ sequences of /, 0+ -, word, /, . symbols, then 1 optional sequence of ? and 1+ non-whitespaces
  13. \b~'; # word boundary
  14. $str = 'example.com www.example.com http://e...content-available-to-author-only...e.com http://w...content-available-to-author-only...e.com https://e...content-available-to-author-only...e.com https://w...content-available-to-author-only...e.com Deciaml Values (1.11) IP Address (123.123.123.123) W.H.O Price values ($11.11)';
  15. preg_match_all($re, $str, $matches);
  16. print_r($matches[0]);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => example.com
    [1] => www.example.com
    [2] => http://e...content-available-to-author-only...e.com
    [3] => http://w...content-available-to-author-only...e.com
    [4] => https://e...content-available-to-author-only...e.com
    [5] => https://w...content-available-to-author-only...e.com
)