--- id: 6a0dcd03ee4e68698080ef6a title: "Challenge 306: HTML Content Extractor" challengeType: 29 dashedName: challenge-306 --- # --description-- Given a string of HTML, return the plain text content with all tags removed. # --hints-- `extract_content('

hello world

')` should return `"hello world"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(extract_content('

hello world

'), "hello world")`) }}) ``` `extract_content('

hello world

')` should return `"hello world"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(extract_content('

hello world

'), "hello world")`) }}) ``` `extract_content('Click me')` should return `"Click me"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(extract_content('Click me'), "Click me")`) }}) ``` `extract_content('

to code
for free
on freecodecamp.org')` should return `"Learn to code for free on freecodecamp.org"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(extract_content('

to code
for free
on freecodecamp.org'), "Learn to code for free on freecodecamp.org")`) }}) ``` `extract_content('

Welcome to My Website.

This is a link to something really important.

A picture
')` should return `"Welcome to My Website.This is a link to something really important.Item oneItem twoItem threeContact us at hello@example.com for more info."`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(extract_content('

Welcome to My Website.

This is a link to something really important.

  • Item one
  • Item two
  • Item three
A picture
'), "Welcome to My Website.This is a link to something really important.Item oneItem twoItem threeContact us at hello@example.com for more info.")`) }}) ``` # --seed-- ## --seed-contents-- ```py def extract_content(html): return html ``` # --solutions-- ```py import re def extract_content(html): return re.sub(r'<[^>]*>', '', html).strip() ```