input: Write a python function to validate URLs using regex.
  assert validate_url("http://www.example.com") == True
  assert validate_url("https://www.example.com") == True
  assert validate_url("ftp://example.com") == True
  assert validate_url("http://localhost") == True
  assert validate_url("http://192.168.0.1") == True
  assert validate_url("http://256.256.256.256") == False
  assert validate_url("example.com") == False
output: import re
  
  def validate_url(url):
      pattern = re.compile(
          r'^(https?|ftp)://'  # http://, https://, ftp://
          r'(\w+(\-\w+)*(\.\w+(\-\w+)*)*|localhost)'  # domain or localhost
          r'(:\d+)?'  # optional port
          r'(/[^\s]*)?$'  # optional path
      )
      return re.match(pattern, url) is not None