input: def html_to_text(html_string: str) -> str:
      """Convert HTML to plain text without using any libraries.
      >>> html_to_text('<div>Hello <b>World</b></div>')
      'Hello World'
      >>> html_to_text('<p>This is a <a href="#">link</a></p>')
      'This is a link'
      """
output:     import re
  
      # Remove HTML tags
      text = re.sub(r'<[^>]+>', '', html_string)
  
      # Replace HTML entities
      text = re.sub(r'&nbsp;', ' ', text)
      text = re.sub(r'&lt;', '<', text)
      text = re.sub(r'&gt;', '>', text)
      text = re.sub(r'&amp;', '&', text)
  
      return text