#C3959. Spam Message Sanitizer
Spam Message Sanitizer
Spam Message Sanitizer
You are given a message and a list of spam words. Your task is to replace every occurrence of a spam word in the message with a sequence of asterisks ('*') whose length is exactly the same as that spam word. Matches should only occur when the spam word appears as a complete word (i.e. has a word boundary on each side). The matching is case sensitive.
Formally, for each spam word \(w\) with length \(|w|\), every occurrence of \(w\) in the message that satisfies the word boundary condition must be replaced by \(\underbrace{**\cdots*}_{|w|}\).
Example: For the input message "This product is amazing and you can buy it now at a discount!" and spam words ["product", "buy", "discount"], the output should be "This ******* is amazing and you can *** it now at a ********!".
inputFormat
The input is read from stdin and has the following format:
- The first line contains the original message (a string).
- The second line contains an integer \(n\) representing the number of spam words.
- The next \(n\) lines each contain a spam word.
outputFormat
Output the sanitized message to stdout as a single line.
## sampleThis product is amazing and you can buy it now at a discount!
3
product
buy
discount
This ******* is amazing and you can *** it now at a ********!