code: def check(text):
      
      err = "links.valid"
      msg = u"Broken link: {}"
  
      regex = re.compile(
          r"""(?i)\b((?:https?://|www\d{0,3}[.]
          |[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+
          |(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)
          |[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019\u21a9]))""",
          re.U | re.X)
  
      errors = []
      for m in re.finditer(regex, text):
          url = m.group(0).strip()
  
          if "http://" not in url and "https://" not in url:
              url = "http://" + url
  
          if is_broken_link(url):
              errors.append((m.start(), m.end(), err, msg.format(url), None))
  
      return errors
docs: Check the text.