--- id: 68cae5b538ff798bbd4da004 title: "Challenge 66: HTML Tag Stripper" challengeType: 29 dashedName: challenge-66 --- # --description-- Given a string of HTML code, remove the tags and return the plain text content. - The input string will contain only valid HTML. - HTML tags may be nested. - Remove the tags and any attributes. For example, `'Click here'` should return `"Click here"`. # --hints-- `strip_tags('Click here')` should return `"Click here"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(strip_tags('Click here'), "Click here")`) }}) ``` `strip_tags('

Hello World!

')` should return `"Hello World!"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(strip_tags('

Hello World!

'), "Hello World!")`) }}) ``` `strip_tags('Cat')` should return an empty string (`""`). ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(strip_tags('Cat'), "")`) }}) ``` `strip_tags('
section
section
')` should return `sectionsection`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(strip_tags('
section
section
'), "sectionsection")`) }}) ``` # --seed-- ## --seed-contents-- ```py def strip_tags(html): return html ``` # --solutions-- ```py import re def strip_tags(html): return re.sub(r'<[^>]*>', '', html) ```