input: Write a python function to validate URLs using regular expressions.
  assert is_valid_url('https://www.google.com') == True
  assert is_valid_url('http://localhost:8000') == True
  assert is_valid_url('ftp://example.com/resource.txt') == True
  assert is_valid_url('https://invalid-url') == False
  assert is_valid_url('not-a-url') == False
output: def is_valid_url(url):
      import re
      pattern = re.compile(
          r'^(https?|ftp)://'  # http://, https://, ftp://
          r'([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+)'  # domain
          r'(:\d+)?'  # optional port
          r'(/.*)?$',  # optional path
          re.IGNORECASE
      )
      return re.match(pattern, url) is not None