Sentence Searcher

Published by Deep Xavier in

Create a function that returns the whole of the first sentence which contains a specific word. Include the full stop at the end of the sentence.

Examples

final String str1 = "For the love of Tesh. She is the love of my life. I am all hers.";
final String str2 = "I have a cat. I have a mat. Things are going swell.";

sentenceSearcher(str1, "LOVE") ➞ "For the love of Tesh."

sentenceSearcher(str1, "LIFE") ➞ "She is the love of my life."

sentenceSearcher(str1, "hers") ➞ "I am all hers."

sentenceSearcher(str2, "MAT") ➞ "I have a mat."

sentenceSearcher(str2, "things") ➞ "Things are going swell."

sentenceSearcher(str2, "flat") ➞ ""

Notes

  • Sentences will always end with a period.
  • Your function should not be case sensitive.
  • Return an empty string if the word isn't found in the sentence.
Watch a quick demo on how Edabit works.