Sophie has found a stash books and she wants to find information about the ancients who lived on the islands. Unfortunately, she does not have a text search module and needs some help. Let's write a program to help her search for keywords on the pages of a book.
You are given some plain text (without tags) and a string with keywords (or parts of words, or letters) separated by spaces. You will need to find all the keywords and put these words into "<span></span>" wrappers to highlight them for Sophie. You can ignore upper or lower cases for the key words, but the original letter cases in the text should remain.
For the cases when keywords contain or intersect each other you should highlight the larger word without nested span tags.
Let's look it with example....
The text and keywords .
The word contains two keywords thus we tag only larger part .
contains two intersected words and and we tag the larger part again .
Be careful, a result like is considered wrong because it contains nested tags.