textual bleeping
Let's say you run a big website for kids and you want to prevent your young users from reading certain naughty words. (Note: it's just a silly example, please don't email me about kids, language, and censorship.) Write a function that takes uncleaned text and a list of naughty words, replaces naughty words found in the text with an equivalent number of asterisks.
Here's an example:
(clean "You are a farty pants." ["fart" "poop"]) ;=> "You are a ****y pants."
(clean "Curse this site!" ["jinx" "curse"]) ;=> "**** this site!"
Bonus: write the reverse function. It takes text and replaces *'s with naughty words of the same length.
Thanks to this site for the challenge idea where it is considered Hard level in Python.
Email submissions to eric@purelyfunctional.tv before July 26, 2020. You can discuss the submissions in the comments below.
Thanks so much @ninjure for showing how to quote the target word. I was worried about this but didn't know about the \Q and \E regex delimiters!