Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. google.com
  2. www.google.com
  3. http//google.com
  4. http//www.google.com
  5. https://google.com
  6. https://www.google.com
  7. ftp://google.com
  8.  
  9. var_dump(
  10. filter_var(
  11. 'http://stack-overflow.com/questions/19437105/using-regx-how-to-validate-url?noredirect=1#comment28819663_19437105',
  12. FILTER_VALIDATE_URL
  13. )
  14. );
  15.  
  16. //output: string(113) "http://stack-overflow.com/questions/19437105/using-regx-how-to-validate-url?noredirect=1#comment28819663_19437105"
  17.  
  18. var_dump(
  19. filter_var(
  20. 'http://stack_overflow.com/questions/19437105/using-regx-how-to-validate-url?noredirect=1#comment28819663_19437105',
  21. FILTER_VALIDATE_URL
  22. )
  23. );
  24.  
  25. //output: bool(false)
  26.  
  27. var_dump(parse_url('http://stackoverflow.com/questions/19437105/using-regx-how-to-validate-url?noredirect=1#comment28819663_19437105'));
  28.  
  29. array(5) {
  30. ["scheme"]=>
  31. string(4) "http"
  32. ["host"]=>
  33. string(17) "stackoverflow.com"
  34. ["path"]=>
  35. string(50) "/questions/19437105/using-regx-how-to-validate-url"
  36. ["query"]=>
  37. string(12) "noredirect=1"
  38. ["fragment"]=>
  39. string(24) "comment28819663_19437105"
  40. }
  41.  
  42. ^((ht|f)tp(s?)://|~/|/)?([w]+:w+@)?([a-zA-Z]{1}([w-]+.)+([w]{2,5}))(:[d]{1,5})?/?(w+.[w]{3,4})?((?w+=w+)?(&w+=w+)*)?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement