input: Write a function to extract titles of all YouTube videos from a given URL. The function should use the `requests` library to fetch the content and `re` library to parse the titles. The function should return a list of extracted titles. If the URL is invalid or the titles cannot be fetched, the function should return an empty list.
  assert extract_titles("https://www.youtube.com/user/Thexvid/videos")==['Video 1', 'Video 2', 'Video 3']
  assert extract_titles("https://www.youtube.com/user/InvalidUserID/videos")==[]
  assert extract_titles("https://www.nonyoutubeurl.com")==[]
output: def extract_titles(url):
      import requests
      import re
      try:
          response = requests.get(url)
          if response.status_code == 200:
              titles = re.findall(r'<title>(.*?)</title>', response.text)
              return titles
          else:
              return []
      except:
          return []